2015-11-13 72 views
0

我使用主題Default-Bootstrap在Prestashop(1.6.1.1。)中設置了一個Webshop。如何在Prestashop的所有頁面中顯示Homeslider

我正在使用「圖片滑塊爲您的主頁」模塊,但它只顯示在主頁上。我嘗試不同的東西,但它們中的任何工作:

  • 我從/homeslider.tpl
  • 我試着通過使用header.tpl以下條件,迫使它去掉了條件{if $page_name =='index'}

    {if $page_name !='index' && $page_name !='pagenotfound'} {include file="$tpl_dir./modules/homeslider/homeslider.tpl"} {/if}

  • 我試圖從/homeslider.tpl直接複製粘貼&代碼到頁眉/ TPL模板,但只有<!-- Module HomeSlider -->註釋顯示任何東西是補間({if isset($homeslider_slides)}條件似乎返回false)。

  • 當然,該模塊被掛在了DisplayTop中,但是在主頁外面仍然沒有任何反應......並且使用DisplayTopColumn不是一個選項。

這裏是homeslider.tpl的代碼:

<!--{if $page_name =='index'} --> 
<!-- Module HomeSlider --> 
    {if isset($homeslider_slides)} 
     <div id="homepage-slider"> 
      {if isset($homeslider_slides.0) && isset($homeslider_slides.0.sizes.1)}{capture name='height'}{$homeslider_slides.0.sizes.1}{/capture}{/if} 
      <ul id="homeslider"{if isset($smarty.capture.height) && $smarty.capture.height} style="max-height:{$smarty.capture.height}px;"{/if}> 
       {foreach from=$homeslider_slides item=slide} 
        {if $slide.active} 
         <li class="homeslider-container"> 
          <a href="{$slide.url|escape:'html':'UTF-8'}" title="{$slide.legend|escape:'html':'UTF-8'}"> 
           <img src="{$link->getMediaLink("`$smarty.const._MODULE_DIR_`homeslider/images/`$slide.image|escape:'htmlall':'UTF-8'`")}"{if isset($slide.size) && $slide.size} {$slide.size}{else} width="100%" height="100%"{/if} alt="{$slide.legend|escape:'htmlall':'UTF-8'}" /> 
          </a> 
          {if isset($slide.description) && trim($slide.description) != ''} 
           <div class="homeslider-description">{$slide.description}</div> 
          {/if} 
         </li> 
        {/if} 
       {/foreach} 
      </ul> 
     </div> 
    {/if} 
<!-- /Module HomeSlider --> 
<!--{/if}--> 

而且一塊header.tpl的:

<div class="header-container"> 
     <header id="header"> 
      {capture name='displayBanner'}{hook h='displayBanner'}{/capture} 
      {if $smarty.capture.displayBanner} 
       <div class="banner"> 
        <div class="container"> 
         <div class="row"> 
          {$smarty.capture.displayBanner} 
         </div> 
        </div> 
       </div> 
      {/if} 
      {capture name='displayNav'}{hook h='displayNav'}{/capture} 
      {if $smarty.capture.displayNav} 
       <div class="nav"> 
        <div class="container"> 
         <div class="row"> 
          <nav>{$smarty.capture.displayNav}</nav> 
         </div> 
        </div> 
       </div> 
      {/if} 
      <div> 
       <div class="container"> 
        <div class="row"> 
         <div id="header_logo"> 
          <a href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}" title="{$shop_name|escape:'html':'UTF-8'}"> 
           <img class="logo img-responsive" src="{$logo_url}" alt="{$shop_name|escape:'html':'UTF-8'}"{if isset($logo_image_width) && $logo_image_width} width="{$logo_image_width}"{/if}{if isset($logo_image_height) && $logo_image_height} height="{$logo_image_height}"{/if}/> 
          </a> 
         </div> 
         {if isset($HOOK_TOP)}{$HOOK_TOP}{/if} 

         /********************************************* 
         HERE I'D LIKE TO DISPLAY THE HOMESLIDER MODULE 
         *********************************************/ 


         <!--{if $page_name !='index' && $page_name !='pagenotfound'} 
         {include file="$tpl_dir./modules/homeslider/homeslider.tpl"} 
         {/if} --> 
        </div> 
       </div> 
      </div> 
     </header> 
    </div> 

我希望我已經說明了問題以及使你可以幫我:)

在此先感謝! iarcas

回答

0

我認爲你在正確的軌道上,你找到了模板中的條件,但你有沒有檢查模塊中的實際鉤子?

看到這個:

homslider.php

public function hookdisplayTopColumn($params) 
{ 
    if (!isset($this->context->controller->php_self) || $this->context->controller->php_self != 'index') 
     return; 
    if (!$this->_prepareHook()) 
     return false; 
    return $this->display(__FILE__, 'homeslider.tpl', $this->getCacheId()); 
} 

所以基本上,你必須做出這個函數的覆蓋:

/清除/模塊/ homeslider/homeslider。 php

<?php 

class HomeSliderOverride extends HomeSlider 
{ 
    public function hookdisplayTopColumn($params) 
    { 
     if (!$this->_prepareHook()) 
      return false; 
     return $this->display(__FILE__, 'homeslider.tpl', $this->getCacheId()); 
    } 
} 
+0

嗨@gskema非常感謝您的回答!我添加了重寫功能,但它似乎不加載homeslider.css和homeslider.js(我只能看到圖像,但沒有動畫和樣式...再次感謝您的幫助! –

+1

只需修復它:D thx! –

相關問題