0

我是 Prestashop 和编程的新手,我正在尝试向 Prestashop 1.4.5 添加一些内容。

我制作了一个新的简单模块,它与 hookHeader 挂钩。我让它工作了,它在商店的顶部显示了 Hello World。但是当我打开站点并打开源代码时,我看到它被添加到 doctype 之前:

你好世界

我的模块 php 看起来像这样 - 我没有使用模板:

if ( !defined( '_CAN_LOAD_FILES_' ) ) 退出;

类primanetskintop扩展模块{

function __construct()
{
    $this->name = "skintop";
    $this->tab = 'front_office_features';
    $this->version = '0.1.0';
    parent::__construct();
    $this->displayName = $this->l('Insert skin top');
    $this->description = $this->l('Skin - ikke slettes');
}

function install()
{
   if (!parent::install() OR !$this->registerHook('header'))
            return false;
    return true;    
}

function uninstal()
{
    if (!parent::uninstall())
        return false;
    return true;
}

public function hookHeader($params) 
{
    echo "Hello World!";
}

为什么hello world不显示hookHeader所在的位置?我究竟做错了什么?

谢谢 :D

4

1 回答 1

2

这是因为您不能使用 echo 将内容添加到标题中。尝试:

public function hookHeader($params) 
{
    return "Hello World!";
}

您可能想从 classes 目录分析 FrontControler.php 以了解其工作原理。

于 2011-12-16T12:21:23.533 回答