2015-08-08 92 views
1

您能告訴我如何在任何頁面上顯示產品名稱下的SKU嗎? 我試圖複製從product.tpl這部分代碼,但它說明不了什麼:(Presta - 在任何頁面上顯示產品名稱下的SKU

在產品頁面(product.tpl)我使用:

{if $product->online_only} 
      <p class="online_only">{l s='Online only'}</p> 
     {/if} 
     <div class="clearfix product-header-cust"> 
      <h1 itemprop="name" style="float: left;">{$product->name|escape:'html':'UTF-8'}</h1> 
      <p id="reduction_percent" style="float: left;" {if !$product->specificPrice || $product->specificPrice.reduction_type != 'percentage'} style="display:none;"{/if}> 
       <span id="reduction_percent_display" class="reduction_percent_display_cust"> 
        {if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}-{$product->specificPrice.reduction*100}%{/if} 
       </span> 
      </p> 
     </div> 
     <p id="product_reference"{if empty($product->reference) || !$product->reference}"{/if}> 
      <label>{l s='Model'} </label> 
      <span class="editable undertitle" itemprop="sku">{if !isset($groups)}{$product->reference|escape:'html':'UTF-8'}{/if}</span> 
     </p> 

,我試圖複製這一部分:

<p id="product_reference"{if empty($product->reference) || !$product->reference}"{/if}> 
      <label>{l s='Model'} </label> 
      <span class="editable undertitle" itemprop="sku">{if !isset($groups)}{$product->reference|escape:'html':'UTF-8'}{/if}</span> 
     </p> 

在此(product_list.tpl):

<h5 itemprop="name" class="product-list-name"> 
         {if isset($product.pack_quantity) && $product.pack_quantity}{$product.pack_quantity|intval|cat:' x '}{/if} 
         <a class="product-name" href="{$product.link|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}" itemprop="url" > 
          {$product.name|truncate:45:'...'|escape:'html':'UTF-8'} 
         </a>  
        </h5> 

所以它看起來像:

<h5 itemprop="name" class="product-list-name"> 
         {if isset($product.pack_quantity) && $product.pack_quantity}{$product.pack_quantity|intval|cat:' x '}{/if} 
         <a class="product-name" href="{$product.link|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}" itemprop="url" > 
          {$product.name|truncate:45:'...'|escape:'html':'UTF-8'} 
         </a>  
        </h5> 
<p id="product_reference"{if empty($product->reference) || !$product->reference}"{/if}> 
      <label>{l s='Model'} </label> 
      <span class="editable undertitle" itemprop="sku">{if !isset($groups)}{$product->reference|escape:'html':'UTF-8'}{/if}</span> 
     </p> 

但它說明不了什麼......

+0

請編輯與相關的代碼和文件名後。 –

+0

我做到了,現在應該更容易理解:) – joryl

回答

2

嘗試: {if isset($product.reference) && $product.reference} <p id="product_reference"> <label>{l s='Model'} </label> <span class="editable undertitle" itemprop="sku"> {$product.reference|escape:'html':'UTF-8'}</span> </p> {/if}

問候,

+0

謝謝soooo多!完美的作品! :)) – joryl

相關問題