Get bean->id when in _headerModuleList.tpl

I’m trying to adjust all the link at the very top when inside a specific bean, but I can’t figure out how to read the current module name/bean->id
(or if it’s even possible).

As a workaround I thought of indicating a custom header, but in meta we can only put custom headerTPL, example

            $viewdefs[mod][DetailView][templateMeta][form][headerTpl] => 'custom/themes/SuiteP/tpls/headerModuleList_c.tpl',

But we can’t indicate a custom headerMODULELIST it seems

Would appreciate your help, have been at it for quite a few hours already

wanted to update with the things I have already tried:

  • Calling $_REQUEST inside .tpl file, but since the URL contains a # it seems like the module name, record etc. are generated by JS

  • Calling $bean->id, $focus->id etc.

  • Setting up a custom view then defining module/record id as a smarty variable > defining a custom header in metadata for that view > reading that smarty variable inside the custom header. Problem is that it seems like we can only specify a custom ‘headerTpl’, but not a custom ‘headerModuleList.tpl’

Figured it out

If we look at the displayHeader() method of the SugarView class we can see what smarty variables are getting assigned.

One of them is $recentRecords

The first item of $recentRecords will contain the current module and record id.

As a test you can put the following in somewhere at the top of _headerModuleList.tpl:


Above is actually incorrect… it doesn’t work sometimes, so please do not use.