0

製品ページに追加のタブを追加する 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');
}

}
?>
4

3 に答える 3

1

jewelleryTabやjewelleryTabContentなどのフックはありません。productTabとproductTabContent(Prestashopコアの一部)を操作する必要があります。ここで、prestahop1.5のフックのリストを確認できますhttp://doc.prestashop.com/display/PS15/ Hooks + in + PrestaShop + 1.5と、prestashopのフックに関する基本情報はhttp://doc.prestashop.com/display/PS14/Understanding+and+using+hooksです。

BelVGからこの拡張機能の作成者であるDenisに連絡することもできます

そしてこの記事の後、Denisは製品タブを追加するための柔軟な拡張機能を開発しました

于 2012-11-17T20:51:30.327 に答える
1

jewelleryTabそしてjewelleryTabContentカスタムフックです。

.tplこれらのフックをテンプレート ファイルに追加する必要があります。

{hook h='jewelleryTab'}
{hook h='jewelleryTabContent'}
于 2015-06-02T02:14:46.807 に答える
0

定義済みのフックのみを使用できます。

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
        );
}
于 2013-12-10T12:47:11.130 に答える