dtwkt46424 2015-03-26 13:08
浏览 62

自定义挂钩在PrestaShop的后台不可见

I've created a module in PrestaShop and registered it to a custom Hook:

public function install()
{
  if (Shop::isFeatureActive())
    Shop::setContext(Shop::CONTEXT_ALL);

  return parent::install() &&
    $this->registerHook('homeProducts') &&
    $this->registerHook('header') &&
    Configuration::updateValue('MYMODULE_NAME', 'my friend');
} 

[...]

public function hookDisplayHomeProducts($params)
{
  $this->context->smarty->assign(
      array(
          'my_module_name' => Configuration::get('MYMODULE_NAME'),
          'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display')
      )
  );
  return $this->display(__FILE__, 'mymodule.tpl');
}

This module works fine with a native hook (for example displayLeftColumn) but when I create a custom one (like "homeProducts") then I am unable to transplant my module to that hook, because it's not visible on the list of hooks.

How can I make this custom hook appear in the list of available hooks?

  • 写回答

2条回答 默认 最新

  • douhui5953 2015-03-29 00:16
    关注

    I think your problem come from your hook name and the associated function.

    What if you call the hook with the 'display' prefix:

    $this->registerHook('displayHomeProducts'),

    then Prestashop will find the associated function hookDisplayHomeProducts, and you will be ok.

    Right now, prestashop search for hookHomeProducts which doesn't exists.

    评论

报告相同问题?

悬赏问题

  • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退