2016-11-16 42 views
0

我使用Prestashop调试器{debuger}找到一些值在我的模板上打印出来(我使用Smarty)。为什么我不能打印使用Prestashop调试器发现的值?

调试器找到我的产品的值(材料),当我尝试使用下面的代码不起作用。

产品名称:

<h5 itemprop="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'}{$features.value} 

// THERE IS THE CODE // 
<p>{$products->features}</p> 

// I TRIED WITH THIS TOO // 
<p>{features->value}</p> 

</a> 
</h5> 

Debuger结果:我想显示 “伯利兹棉花&羊绒” 值 debuger

回答

0

这是因为{$features}是一个数组。

这将打印你想要什么:

{$features|@print_r} 

然后访问该值:

{if isset($features) && $features} 
     <!-- Data sheet --> 
     <section class="page-product-box"> 
      <h3 class="page-product-heading">{l s='Data sheet'}</h3> 
      <table class="table-data-sheet"> 
       {foreach from=$features item=feature} 
       <tr class="{cycle values="odd,even"}"> 
        {if isset($feature.value)} 
        <td>{$feature.name|escape:'html':'UTF-8'}</td> 
        <td>{$feature.value|escape:'html':'UTF-8'}</td> 
        {/if} 
       </tr> 
       {/foreach} 
      </table> 
     </section> 
     <!--end Data sheet --> 
    {/if} 

从默认的自举的主题product.tpl。

+0

您已经接近解决方案,上面的代码为每个产品输出数字“1” –

+0

@SashaChirico我编辑了答案。祝你好运。 ; ) – JazZ

+0

@SashaChirico这个答案解决了你的问题? – JazZ