“ un-group”产品功能

时间:2019-06-24 16:53:30

标签: prestashop smarty prestashop-1.7

在product-details.tpl中,将功能分组后,将它们打印在单个

例如:

onRemove

我要打印以下内容: 代码:

<dl>
   <dt>FEATURE</dt>
   <dd>Value1 Value2 Value3</dd>
</dl>

这是原始代码

<dl>
   <dt>FEATURE</dt>
   <dd>
       <span title="value1">Value1</span>
       <span title="value2">Value2</span>
       <span title="value2">Value3</span>
   </dd>
</dl>

我尝试过

  {block name='product_features'}
    {if $product.grouped_features}
      <section>
        <h3>{l s='Data sheet' d='Shop.Theme.Catalog'}</h3>
        <dl>
          {foreach from=$product.grouped_features item=feature}
            <dt>{$feature.name}</dt>
            <dd>{$feature.value|escape:'htmlall'|nl2br nofilter}</dd>
          {/foreach}
        </dl>
      </section>
    {/if}
  {/block}

但是当然不行。.

非常感谢您提供任何可能的帮助。 谢谢

1 个答案:

答案 0 :(得分:1)

尝试:

{block name='product_features'}
    {if $product.grouped_features}
        <section>
            <h3>{l s='Data sheet' d='Shop.Theme.Catalog'}</h3>
            <dl>
                {foreach from=$product.grouped_features item=feature}
                    <dt>{$feature.name}</dt>
                    {assign var=detail_feature value="<br />"|explode:$feature.value} 
                    <dd>
                        {foreach from=$detail_feature item=det_feature}
                            <span title="{$det_feature|escape:'htmlall'|nl2br nofilter}">{$det_feature|escape:'htmlall'|nl2br nofilter}</span>
                        {/foreach}
                    </dd>
                {/foreach}
            </dl>
        </section>
    {/if}
{/block}