prestashop-1.7 - 如何在 Prestashop 1.7 registerHook('customerAccount') 中使用它?
问题描述
如何使用这个 displayCustomerAccount ?我想在这里显示一些信息 /index.php?controller=my-account
解决方案
我不确定你到底想做什么,但这个钩子是专门用来在 index.php?controller=my-account 的页面上添加链接的,而不是任何类型的文本或信息。
无论如何,要在此页面上添加元素,首先通过在模块类的安装函数中添加 $this->registerHook('customerAccount') 将模块挂钩到 customerAccount,如下所示:
public function install()
{
if (!parent::install() ||
!$this->registerHook('customerAccount')
) {
return false;
}
return true;
}
然后将以下函数添加到模块的类中
public function hookCustomerAccount()
{
$this->smarty->assign(array(
'your_link' => $your_link,
'any_variable_needed' => $any_variable_needed
));
return $this->display(__FILE__, 'my_account.tpl');
}
最后,创建一个新的 tpl 文件 your_module_folder\views\templates\hook\my_account.tpl 并在其中添加您的信息。正如我之前所说,通常你会找到这样的链接:
<a class="col-lg-4 col-md-6 col-sm-6 col-xs-12" id="your_id" href="{$your_link|escape:'htmlall':'UTF-8'}">
<span class="link-item">
<i class="material-icons"></i>
{l s='Your link' mod='your_module'}
</span>
</a>
推荐阅读
- react-select - 如何自定义下拉菜单
- javascript - 根据时间显示不同的图像
- python - 使用 Python 从 Jira 中提取所有问题时,有没有办法将最新的活动历史记录添加到问题列表中?
- angular - if() 返回的单元测试;在一个函数中
- vb.net - 在没有 Office 365 的计算机上安装 Office 365 组件
- linux - 如何为需要以特定顺序运行的 2 个或更多服务器构建启动/关闭脚本?
- ros - 在动力学上安装turtlebot
- r - 如何使用 Shiny 向 mongodb 提交多种数据类型(数组、字符串等)?
- mqtt - MQTT Sparkplug中的Bdseq和Seq号有什么区别
- python - Pandas groupby 语句查找范围有问题