'.$this->l('Please consider using this function.
This function is only for advance user,
It will load other module and display in column of Appagebuilder.
With some module have ID in wrapper DIV, your site will have Javascript Conflicts.
We will not support this error.').'
',
)
);
return $inputs;
}
public function prepareFontContent($assign, $module = null)
{
// validate module
unset($module);
$form_attr = $assign['formAtts'];
$context = Context::getContext();
if (isset($form_attr['hook']) && isset($form_attr['name_module']) && Module::isEnabled($form_attr['name_module'])) {
$assign['apContent'] = $this->execModuleHook($form_attr['hook'], array(), $form_attr['name_module'], false, $context->shop->id);
}
return $assign;
}
public static function execModuleHook($hook_name = null, $hook_args = array(), $module_name = null, $use_push = false, $id_shop = null)
{
static $disable_non_native_modules = null;
if ($disable_non_native_modules === null) {
$disable_non_native_modules = (bool)Configuration::get('PS_DISABLE_NON_NATIVE_MODULE');
}
// Check arguments validity
if (!Validate::isModuleName($module_name) || !Validate::isHookName($hook_name)) {
return '';
}
//throw new PrestaShopException('Invalid module name or hook name');
// If no modules associated to hook_name or recompatible hook name, we stop the function
if (!Hook::getHookModuleExecList($hook_name)) {
return '';
}
// Check if hook exists
if (!$id_hook = Hook::getIdByName($hook_name)) {
return false;
}
// Store list of executed hooks on this page
Hook::$executed_hooks[$id_hook] = $hook_name;
$context = Context::getContext();
if (!isset($hook_args['cookie']) || !$hook_args['cookie']) {
$hook_args['cookie'] = $context->cookie;
}
if (!isset($hook_args['cart']) || !$hook_args['cart']) {
$hook_args['cart'] = $context->cart;
}
$retro_hook_name = Hook::getRetroHookName($hook_name);
// Look on modules list
$altern = 0;
$output = '';
if ($disable_non_native_modules && !isset(Hook::$native_module)) {
Hook::$native_module = Module::getNativeModuleList();
}
$different_shop = false;
if ($id_shop !== null && Validate::isUnsignedId($id_shop) && $id_shop != $context->shop->getContextShopID()) {
$old_context = $context->shop->getContext();
$old_shop = clone $context->shop;
$shop = new Shop((int)$id_shop);
if (Validate::isLoadedObject($shop)) {
$context->shop = $shop;
$context->shop->setContext(Shop::CONTEXT_SHOP, $shop->id);
$different_shop = true;
}
}
// Check errors
if ((bool)$disable_non_native_modules && Hook::$native_module && count(Hook::$native_module) && !in_array($module_name, self::$native_module)) {
return;
}
if (!($module_instance = Module::getInstanceByName($module_name))) {
return;
}
if ($use_push && !$module_instance->allow_push) {
return;
}
// Check which / if method is callable
$hook_callable = is_callable(array($module_instance, 'hook'.$hook_name));
$hook_retro_callable = is_callable(array($module_instance, 'hook'.$retro_hook_name));
if (($hook_callable || $hook_retro_callable)) {
$hook_args['altern'] = ++$altern;
if ($use_push && isset($module_instance->push_filename) && file_exists($module_instance->push_filename)) {
Tools::waitUntilFileIsModified($module_instance->push_filename, $module_instance->push_time_limit);
}
if ($hook_callable) {
// Call hook method
$display = $module_instance->{'hook'.$hook_name}($hook_args);
} elseif ($hook_retro_callable) {
$display = $module_instance->{'hook'.$retro_hook_name}($hook_args);
}
$output .= $display;
} elseif (Hook::isDisplayHookName($hook_name)) {
if ($module_instance instanceof WidgetInterface) {
$display = Hook::coreRenderWidget($module_instance, $hook_name, $hook_args);
$output .= $display;
}
}
if ($different_shop) {
$context->shop = $old_shop;
$context->shop->setContext($old_context, $shop->id);
}
return $output; // Return html string
}
}