public function processHookFunction($params, &$smarty)
    {
        $hookName   = $this->getParam($params, 'name');
        $module     = intval($this->getParam($params, 'module', 0));
        $moduleCode = $this->getParam($params, 'modulecode', "");

        $type = $smarty->getTemplateDefinition()->getType();

        $event = new HookRenderEvent($hookName, $params, $smarty->getTemplateVars());

        $event->setArguments($this->getArgumentsFromParams($params));

        $eventName = sprintf('hook.%s.%s', $type, $hookName);

        // this is a hook specific to a module
        if (0 === $module && "" !== $moduleCode) {
            if (null !== $mod = ModuleQuery::create()->findOneByCode($moduleCode)) {
                $module = $mod->getId();
            }
        }
        if (0 !== $module) {
            $eventName .= '.' . $module;
        }

        $this->getDispatcher()->dispatch($eventName, $event);

        $content = trim($event->dump());

        if ($this->debug && $smarty->getRequest()->get('SHOW_HOOK')) {
            $content = self::showHook($hookName, $params) . $content;
        }

        $this->hookResults[$hookName] = $content;

        // support for compatibility with module_include
        if ($type === TemplateDefinition::BACK_OFFICE) {
            $content .= $this->moduleIncludeCompat($params, $smarty);
        }

        return $content;
    }