0

我正在尝试从模板文件中调用我的自定义钩子。我已经在 ps_hook 表中插入了钩子。我创建了一个模块并将其链接到钩子。我还使用 Modules -> Postions -> Transplant a module 将模块嫁接到了钩子上。

这是 mymodule.php 文件。

  <?php
 if (!defined('_PS_VERSION_'))
exit;

class MyModule extends Module
{
public function __construct()
{
$this->name = 'mymodule';
$this->tab = 'front_office_features';
$this->version = 1.0;
$this->author = 'Sarfaraz Raj';
$this->need_instance = 0;

parent::__construct();

$this->displayName = $this->l('My module');
$this->description = $this->l('Description of my module.');

}

public function install()
{
if (parent::install() == false OR !$this->registerHook('displayDateSlot'))
return false;
return true;
}
public function hookDisplayDateSlot( $params )
{
 //global $smarty;
$this->context->smarty->assign(
    array(
       // 'my_module_name' => Configuration::get('MYMODULE_NAME'),
       // 'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display'),
        'my_module_message' => $this->l('This is a simple text message'), 
        'HOOK_DISPLAY_DATESLOT' =>  Hook::exec('displayDateSlot')
    )
);

  return $this->display(__FILE__,'mymodule.tpl');
}


public function hookRightColumn($params)
{
 return $this->hookDisplayDateSlot($params);
}
 }
 ?>

我只想知道我应该在哪里声明 'HOOK_DISPLAY_DATESLOT' => Hook::exec('displayDateSlot') 行。我的钩子的名称是 displayDateSlot。

4

1 回答 1

0

不需要再写 'HOOK_DISPLAY_DATESLOT' => Hook::exec('displayDateSlot')

您的钩子已建立,您可以通过管理端安装它并查看前面的外观。

于 2014-04-18T10:35:32.550 回答