Logic hook "after_ui_footer" not triggering

Version: 7.6.2

I’m trying to use a “after_ui_footer” logic hook in order to pull in a javascript file after the subpanel(s) have been loaded in my custom module. I’ve set the following in my custom/modules/mymodule/logic_hooks.php:


$hook_array['after_ui_footer'][] = [
    10,
    'Document Subpanel Changes with JS/JQ',
    'custom/Extension/modules/mymodule/Ext/LogicHooksCode/documentSubpanel.php',
    'mymodule_documentSubpanel',
    'documentSubpanel',
];

and this is the basic content of my documentSubpanel.php file:


if (!defined('sugarEntry') || !sugarEntry) {
    die ('Not A Valid Entry Point');
}
class mymodule_documentSubpanel
{
    /**
     *
     */
    public function documentSubpanel($event, $arguments)
    {
        if ($_REQUEST['module'] == 'mymodule' && $_REQUEST['action'] == 'DetailView') {
echo 'INTO AFTERFOOTER';
echo '<script type="text/javascript" src="custom/modules/mymodule/js/mymodule_form_detail_postdom.js"></script>';
        }
    }
}

If I set this to occur as an “after_ui_frame” logic hook it works fine.

Why is this not triggering when I need it to?

On reverse engineering the core code for this, I believe I may have found a problem.

In file: include/MVC/View/SugarView.php at line 188, we have the following:


        $GLOBALS['logic_hook']->call_custom_logic('', 'after_ui_footer');

which looks as though it’s calling the logic hook without a module identifier. Any custom (or other) modules that have specific after_ui_footer hooks will -not- be processed.

I believe this line should be:


$GLOBALS['logic_hook']->call_custom_logic($this->module, 'after_ui_footer');

which makes my initial query actually work.

Hi,
Nice reverse engineering :wink:

But, don’t forget, we can have logic_hook specific for module… and too globaly (for all modules).
And if i see this : http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.6/Logic_Hooks/Application_Hooks/after_ui_footer/

This is not a “module specific hook”.

Regards

You’re absolutely right; this hook is an application-wide one and not module-related per se; however, the same could be said of the after_ui_frame which, in fact, -does- pull in the module name in it’s context call.

I’ll try to place my code into the more global custom/modules/logic_hooks.php and add the module/view conditions into the called function, but to be honest if there are several such hooks to be placed specifically for custom modules, isn’t it a more feasible idea to directly relate these to the modules rather than a series of globals with conditionals?

you could add some code that first checks which is the module calling the hook and executes the rest only it it’s the desired module(s)

Yes… that’s why the following:


if ($_REQUEST['module'] == 'mymodule' && $_REQUEST['action'] == 'DetailView') {
	// process if true
}

is inserted into the hook script.