Alexander Hein Alexander Hein - 3 months ago 26
Smarty Question

How to filter a loop with php/smarty?

This code shows me all selections I have made.

How can I filter this and only show the selection of a specific Group?

For example

{if $sConfigurator.groupID == 113}


{$configurator = $sArticle.sConfigurator}
{foreach $configurator as $configuratorGroup}
{foreach $configuratorGroup.values as $option}

{if $option.selected}
<div class="selected">
<div class="group">{$configuratorGroup.groupname}</div>
<div class="option">{$option.optionname}</div>
</div>
{/if}

{/foreach}
{/foreach}

Answer

I'm also not sure what you mean or what configurator your code is about... Maybe just add the condition to the if?

{if $option.selected && $configuratorGroup.id == 113}
    <div class="selected">
        <div class="group">{$configuratorGroup.groupname}</div>
        <div class="option">{$option.optionname}</div>
    </div>
{/if}
Comments