1

我正在 prestashop 中开发一个模块。该模块已连接到左列和右列,并且可以正常工作。现在我想在产品页脚页面中显示模块输出。因此,有人可以告诉我如何将我的模块连接到产品详细信息页面吗?任何帮助和建议都将是非常可观的。

我的 leftColumn 和 rightColumn 代码是这样的

 function hookLeftColumn()
  {
    $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));
    global $cookie, $smarty;
    $value=array();
    $result="SELECT status,app_id from "._DB_PREFIX_."storeblocks";
    $value=Db::getInstance()->ExecuteS($result);
    $smarty->assign('array',$value);
    $smarty->assign('default',$defaultLanguage);
    return $this->display(__FILE__, 'stores.tpl');
  }

  function hookRightColumn()
  {
    return $this->hookLeftColumn();
  }
4

2 回答 2

4

对于产品页面,PS 中有几个可用的钩子。

您可以使用displayLeftColumnProduct挂钩,该挂钩挂钩产品图像下方的模块。您还可以使用用于右侧部分的displayRightColumnProduct 。

另一组钩子是displayProductTabdisplayProductTabContent,它们用于产品页面上的选项卡。

如果这些钩子对您没有帮助,那么您可以通过其他几种方法获得结果。您可以将您的模块挂接到任何更适合您需要的钩子上,然后使用 css position 和 lft 、 top 等将该钩子移动到所需的位置。

如果这不是一个选择,那么您将需要创建自己的挂钩,然后在产品页面上使用该挂钩。请阅读此内容以创建您自己的钩子

http://www.programmingtunes.com/creating-new-prestashop-hook/

另外对于 PS 中的钩子的完整列表,请阅读 PS 文档中的这篇文章

http://doc.prestashop.com/display/PS15/Hooks+in+PrestaShop+1.5

如果您还需要任何其他详细信息,请告诉我。

谢谢

于 2013-05-18T11:38:44.500 回答
3

注意:这个答案是关于 prestashop 1.5 的,你也可以将它用于 prestashop 1.6。

如果您的意思product details page是更多信息选项卡,如下图所示,我可以帮助您

细节挂钩

step1.you 应该在模块的 install 函数中安装两个钩子

   public function install() { 
    return   parent::install() &&
              $this->registerHook('displayProductTab')&&
               $this->registerHook('displayProductTabContent')
                 }

step2:你应该使用它们并返回一些我想添加一个我使用的新标签的html代码。
注意:id是动态的,你改变它,但class静态的应该用作selected. 还href链接到内容 ID(您在第 3 步中看到)

   public function hookDisplayProductTab($params) {
      return '<li>
              <a id="myid" class="selected"  
               href="#linked">mytab</a>
                </li>'
               }

第 3 步:如果需要,当您单击 mytab 时会显示它的内容,您可以添加其他功能。注意:前面函数中的 href="#linked" 链接到 id="linked"。

   public function hookDisplayProductTabContent($params){

      return <div id="linked" class="rte">
              <div class="product-overview-full">
               my contents
                </div>
                 </div>
              }

高级:在您的 .tpl 中写入您的 html 或 smarty 并使用此代码返回主题

       return $this->display(__FILE__, 'mytpl.tpl') ;

此致。

于 2013-11-21T13:11:55.090 回答