【问题标题】:"un-group" Product Features“取消分组”产品功能
【发布时间】:2019-11-06 12:25:56
【问题描述】:

在 product-details.tpl 中,功能在分组时打印在单个

例如:

<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}

我试过了

{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>{foreach $feature.value}<span title="{$feature.value|replace:' ':'_'}">{$feature.value|escape:'htmlall'|nl2br nofilter}</span>{/foreach}</dd>
          {/foreach}
        </dl>
      </section>
{/if}

但是当然不行..

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

【问题讨论】:

    标签: prestashop smarty prestashop-1.7


    【解决方案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}
    

    【讨论】:

    • 感谢您的回答。几乎,但是当值超过 1 个单词时,它也会将它们分开。例如,值是: Value One 它打印 Value One
    • 好的,那么你的分隔符是什么?
    • 这些值由
      分隔
    • 现在打印 Value 1
      Value 2
    猜你喜欢
    • 2011-03-09
    • 2018-05-06
    • 1970-01-01
    • 1970-01-01
    • 2021-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多