簡體   English   中英

Prestashop 1.5.4使用自定義鈎子創建自定義模塊

[英]Prestashop 1.5.4 creating custom module with custom hook

我試過用很多方法創建自己的模塊,它有一個必須出現在header.tpl列中的鈎子。 不幸的是,我遵循哪個教程,它不起作用。 我究竟做錯了什么? 例如我的步驟:

第1步:創建我的模塊事件

dir:prestashop \\ modules \\ events文件:logo.gif,logo.png,events.tpl,events.php

在events.php中:

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

class Events extends Module
{
public function __construct()
    {
    $this->name = 'events';
    $this->tab = 'front_office_features';
    $this->version = '1.0';
    $this->author = 'Dinizworld';
    $this->need_instance = 0;

    parent::__construct();

    $this->displayName = $this->l('Dinizworld Events');
    $this->description = $this->l('Upcoming events.');
    $this->confirmUninstall = $this->l('Are you sure you want to delete this module?');
    }
public function install()
    {
    return parent::install() && $this->registerHook('hookEvents');
    }
public function hookEvents($params)
    {
    //return $this->display(__FILE__, 'events.tpl');
    return "test message";
    }
}

第2步:添加鈎子

在header.tpl中的正確位置:{hook h ='hookEvents'}

步驟3在adminpanel中安裝模塊我看到鈎子被移植到我的模塊上。

然后沒有出現。 當我嘗試使用例如HOOK_HOME時,我的測試消息是可見的。 但不是我自己的鈎子。 我究竟做錯了什么?

嘗試

$this->registerHook('events')

代替

$this->registerHook('hookEvents')

編輯

並在header.tpl中

{hook h='events'}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM