在聪明的多行上显示每个结果

Show each result on a smarty multiple lines

我试图在多行中显示 table 的结果。我有一个带有键 => 值的 table。目前我的代码看起来像这样,但只显示一个值:

{$i = 0}
            {foreach from=$features item=feature}
                <div class="col-xs-12 col-md-12 col-lg-12">
                    <div class="row">
                        {if isset($feature.values) && $feature.id_feature == 199}
                            {*<div class="col-xs-4 col-md-4 col-lg-4">
                                <img src="{$img_dir}icon-{$feature.values|lower|replace:' ':'-'}-black.png">
                            </div>*}
                            <div class="col-xs-8 col-md-8 col-lg-8">
                                <p class="accord_title">{$feature.values[$i]|escape:'html':'UTF-8'}</p>
                            </div>
                            {$feature.values|@print_r}
                        {/if}
                    </div>
                </div>

                {$i = $i+1}
            {/foreach}

我希望最终能像这样

finality

我的 table 现在看起来像这样:

    $features   Smarty_Variable Object (3)
->value = Array (4)
  141 => Array (4)
    values => Array (1)
      0 => "Bouteille 75cl"
    name => "Contenance"
    id_feature => "141"
    value => "Bouteille 75cl"
  195 => Array (4)
    values => Array (1)
      0 => "Vin Moelleux"
    name => "Typologie"
    id_feature => "195"
    value => "Vin Moelleux"
  197 => Array (4)
    values => Array (1)
      0 => "Gewurztraminer Sélection de Grains No..."
    name => "Appellation"
    id_feature => "197"
    value => "Gewurztraminer Sélection de Grains No..."
  199 => Array (4)
    values => Array (11)
      0 => "Charcuterie"
      1 => "Desserts"
      2 => "Fruits de mer"
      3 => "Plats en sauce"
      4 => "Plats épicés"
      5 => "Poissons"
      6 => "Viandes blanches"
      7 => "Viandes rouges"
      8 => "Volaille"
      9 => "Apéritifs"
      10 => "Fromages"
    name => "Accords mets-vin"
    id_feature => "199"
    value => "Charcuterie, Desserts, Fruits de mer,..."
->nocache = false
->scope = "file:D:\WAMP\www\vm.fr/themes/..."

感谢您的帮助。

我找到了解决方法,这里是解决方案:

{$i = 0}
            {foreach from=$features item=feature}
                {if isset($feature.values) && $feature.id_feature == 199}
                    {foreach from=$feature.values item=val}
                        <div class="col-xs-12 col-md-12 col-lg-12">
                            <div class="row">
                                <div class="col-xs-4 col-md-4 col-lg-4">
                                    <img src="{$img_dir}icon-{$val|lower|replace:' ':'-'}-black.png">
                                </div>
                                <div class="col-xs-8 col-md-8 col-lg-8">
                                    <p class="accord_title">{$val|escape:'html':'UTF-8'}</p>
                                </div>
                            </div>
                        </div>
                        {$i = $i +1}
                    {/foreach}
                {/if}
            {/foreach}

您不需要使用 $i :

{foreach from=$features item=feature}
    {if isset($feature.values) && $feature.id_feature == 199}
        {foreach from=$feature.values item=val}
            <div class="row">
                <p>{$val|escape:'html':'UTF-8'}</p>
            </div>
        {/foreach}
    {/if}
{/foreach}