Prestashop模块已安装,但无法按预期工作

Prestashop模块已安装,但无法按预期工作,prestashop,Prestashop,我有一个prestashop插件,它在产品页面上添加了一个额外的选项卡: <?php // Disable direct addressing to the script: if (!defined('_PS_VERSION_')) exit; //Create module class: class producttab extends Module { //Class constructor that contains its configuration: public

我有一个prestashop插件,它在产品页面上添加了一个额外的选项卡:

<?php

// Disable direct addressing to the script:
if (!defined('_PS_VERSION_'))
    exit;

//Create module class:
class producttab extends Module {

//Class constructor that contains its configuration:
public function __construct()
{
    $this->name = "producttab"; //Module name
    $this->tab = "front_office_features"; //Tab with the module in Prestashop back-office modules list
    $this->version = "1.0"; // Module version
    $this->author = "BelVG";  // Module author 
    parent::__construct();
    $this->displayName = $this->l("Product Tab"); // Module title
    $this->description = $this->l("Module creates a new tab on the frontend product page "); // Module description 
}

//Module installation-method:
public function install()
{
    return (parent::install()
            AND $this->registerHook('productTab') //Register productTab hook that will display the tab button
            AND $this->registerHook('productTabContent') //Register productTabContent hook that will display the tab content
            );
}

//Module deinstallation-method:
public function uninstall()
{
    return (parent::uninstall()
            AND $this->unregisterHook('productTab')
            AND $this->unregisterHook('productTabContent')); // Delete all hooks, registered by the  module 
}

//Method will be called while performing the "ProductTab" hook (tab buttons generation):
public function hookProductTab($params)
{
    global $smarty;
    //Call the template containing the HTML-code ?? our button
    return $this->display(__FILE__ , 'tpl/productTab.tpl');
}

public function hookProductTabContent($params)
{
    global $smarty;
    //Transfer the new tab content into template via smatry
    //( it is optional as far as the content can be assigned directly in the template)
     $result = Db::getInstance()->executeS('SELECT * FROM ps_cms_lang WHERE id_cms =14');

$smarty->assign('content', $result);
    // Call the template containing the HTML-code of our new tab content:
    return $this->display(__FILE__ , 'tpl/productTabContent.tpl');
}

}
?>

模块按预期工作。我正在尝试修改相同的代码以添加另一个选项卡。由于某些原因,新模块已安装,但该选项卡未显示。有什么我遗漏的吗

<?php

// Disable direct addressing to the script:
if (!defined('_PS_VERSION_'))
exit;

//Create module class:
class jewellerytab extends Module {

//Class constructor that contains its configuration:
public function __construct()
{
    $this->name = "jewellerytab"; //Module name
    $this->tab = "front_office_features"; //Tab with the module in Prestashop back-office modules list
    $this->version = "1.0"; // Module version
    $this->author = "Mike Rifgin";  // Module author 
    parent::__construct();
    $this->displayName = $this->l("jewellery Tab"); // Module title
    $this->description = $this->l("Module creates a new tab on the frontend jewellery page "); // Module description 
}

//Module installation-method:
public function install()
{
    return (parent::install()
            AND $this->registerHook('jewelleryTab') //Register jewelleryTab hook that will display the tab button
            AND $this->registerHook('jewelleryTabContent') //Register jewelleryTabContent hook that will display the tab content
            );
}

//Module deinstallation-method:
public function uninstall()
{
    return (parent::uninstall()
            AND $this->unregisterHook('jewelleryTab')
            AND $this->unregisterHook('jewelleryTabContent')); // Delete all hooks, registered by the  module 
}

//Method will be called while performing the "jewelleryTab" hook (tab buttons generation):
public function hookjewelleryTab($params)
{
    global $smarty;
    //Call the template containing the HTML-code ?? our button
    return $this->display(__FILE__ , 'tpl/jewelleryTab.tpl');
}

public function hookjewelleryTabContent($params)
{
    global $smarty;
    //Transfer the new tab content into template via smatry
    //( it is optional as far as the content can be assigned directly in the template)
     $result = Db::getInstance()->executeS('SELECT * FROM ps_cms_lang WHERE id_cms =14');

$smarty->assign('content', $result);
    // Call the template containing the HTML-code of our new tab content:
    return $this->display(__FILE__ , 'tpl/jewelleryTabContent.tpl');
}

}
?>

没有像jewelleryTab和jewelleryTabContent这样的钩子,您需要使用productTab和productTabContent(它是Prestashop core的一部分),在这里您可以找到prestahop 1.5的钩子列表以及有关Prestashop中钩子的一些基本信息

你也可以试着联系丹尼斯


在这篇文章之后,Denis开发了flexible

,我们只能使用预定义的挂钩

您可以使用与相同的挂钩,而不是jewelleryTab和jewelleryTabContent。

希望钩子可以重复使用

public function install()
{
       return (parent::install()
        AND $this->registerHook('productTab') //Register productTab hook that will display the tab button
        AND $this->registerHook('productTabContent') //Register productTabContent hook that will display the tab content
        );
}

jewelleryTab
jewelleryTabContent
是自定义挂钩

您需要将这些挂钩添加到
.tpl
模板文件中:

{hook h='jewelleryTab'}
{hook h='jewelleryTabContent'}