如何檢查項目的名稱並顯示它?如何檢查迭代有名字?
我currenty代碼,檢查,如果該項目爲偶數或奇數:
{foreach $panels as $item}
{if [email protected] is odd}
{outputHomePanels}
{/if}
{/foreach}
整個代碼:
{function name=outputHomePanels}
<div menuItemName="{$item->getName()}" class="panel panel-default panel-accent-{$item->getExtra('color')}{if $item->getClass()} {$item->getClass()}{/if} {$item->getName()}"{if $item->getAttribute('id')} id="{$item->getAttribute('id')}"{/if}>
<div class="panel-heading">
<h3 class="panel-title">
{if $item->getExtra('btn-link') && $item->getExtra('btn-text')}
<div class="pull-right">
<a href="{$item->getExtra('btn-link')}" class="more-link">
{$item->getExtra('btn-text')}
</a>
</div>
{/if}
<div class="clientarea-icon {$item->getName()}">
{if $item->hasIcon()}<i class="{$item->getIcon()}"></i>{/if}
</div>
<div class="clientarea-title">
{$item->getLabel()}
</div>
{if $item->hasBadge()}<span class="badge">{$item->getBadge()}</span>{/if}
</h3>
</div>
{if $item->hasBodyHtml()}
<div class="panel-body">
{$item->getBodyHtml()}
</div>
{/if}
{if $item->hasChildren()}
<div class="list-group{if $item->getChildrenAttribute('class')} {$item->getChildrenAttribute('class')}{/if}">
{foreach $item->getChildren() as $childItem}
{if $childItem->getUri()}
<a menuItemName="{$childItem->getName()}" href="{$childItem->getUri()}" class="list-group-item{if $childItem->getClass()} {$childItem->getClass()}{/if}{if $childItem->isCurrent()} active{/if}"{if $childItem->getAttribute('dataToggleTab')} data-toggle="tab"{/if}{if $childItem->getAttribute('target')} target="{$childItem->getAttribute('target')}"{/if} id="{$childItem->getId()}">
<div class="clientarea-icon {$childItem->getLabel()|stristr:'<' : true}">
<i class="icon-clientarea-product"></i>
</div>
<div class="clientarea-title">
{assign var="splitItem" value=" - "|explode:$childItem->getLabel()}
{$splitItem[1]}
</div>
{if $childItem->hasBadge()} <span class="badge">{$childItem->getBadge()}</span>{/if}
</a>
{else}
<div menuItemName="{$childItem->getName()}" class="list-group-item{if $childItem->getClass()} {$childItem->getClass()}{/if}" id="{$childItem->getId()}">
{if $childItem->hasIcon()}<i class="{$childItem->getIcon()}"></i> {/if}
{$childItem->getLabel()}
{if $childItem->hasBadge()} <span class="badge">{$childItem->getBadge()}</span>{/if}
</div>
{/if}
{/foreach}
</div>
{/if}
</div>
{/function}
我需要檢查,如果該項目的名稱是「有源產品/服務」。
我該如何做到這一點?
這是行不通的? {if $ item @ name ==「Active Products/Services」}} – vitorsdcs
解釋一下,在這裏添加$ panels數據。 –
@GovindSamrow我編輯更多代碼。 –