簡體   English   中英

Prestashop模塊掛鈎到產品頁面

[英]Prestashop module hook to product pages

我在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();
  }

對於產品頁面,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

讓我知道您是否還需要其他詳細信息。

謝謝

注意:這個答案是關於prestashop 1.5的,您也可以將其用於prestashop 1.6。

如果您對product details page是“更多信息”標簽(如我在下面的圖片中所示),那么我可以為您提供幫助

細節鈎

步驟1.您應在模塊中安裝兩個鈎子以安裝功能

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

第二步:您應該使用它們並返回一些我想要添加新標簽的HTML代碼。
注意: id是動態的,您可以對其進行更改,但class是靜態的,應將其用作selected href也鏈接到內容ID(您在步驟3中看到了)

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

第三步:如果要在單擊mytab時顯示此內容,則可以添加其他功能。 注意:上一個功能的href =“#linked”已鏈接到id =“ linked”。

   public function hookDisplayProductTabContent($params){

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

高級:將您的html或smarty寫入.tpl並返回此代碼的主題

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

最好的祝福。

暫無
暫無

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

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