试图通过smarty解决Shopware中子子类别访问的问题,但根本不确定如何做到这一点。也许有人知道。
<!-- THIS WORKS -->
{if $Category.sub}
{foreach $Category.sub as $sub}
<li>
<a href="#">
<span itemprop="name">{$sub.name}</span>
</a>
</li>
{/foreach}
{/if}
<!-- THIS DOESN'T WORK -->
{if $Category.sub.sub}
{foreach $Category.sub.sub as $subsub}
<li>
<a href="#">
<span itemprop="name">{$subsub.name}</span>
</a>
</li>
{/foreach}
{/if}
答案 0 :(得分:0)
请查看以上示例:
{foreach $Category.sub as $categoryItem}
{foreach $categoryItem.sub as $subsub}
<li>
<a href="#">
<span itemprop="name">{$subsub.name}</span>
</a>
</li>
{/foreach}
{/foreach}
高级示例:
{foreach $Category.sub as $number => $categoryItem}
{if $categoryItem.childrenCount}
<ul id="submenu-{$number}" {if $categoryItem.flag}class="is--active"{/if}>
{if $categoryItem.cmsHeadline}
<li class="menu--list-item item--level-1">
<span class="menu--list-item-title">{$categoryItem.cmsHeadline}</span>
</li>
{/if}
{foreach $categoryItem.sub as $subcategory}
{if $subcategory.hideTop}
{continue}
{/if}
{$categoryLink = $subcategory.link}
{if $subcategory.external}
{$categoryLink = $subcategory.external}
{/if}
<li class="menu--list-item item--level-1{if $subcategory.flag} item--is-active{/if}">
<a href="{$categoryLink|escapeHtml}" class="menu--list-item-link" title="{$subcategory.name|escape}">{$subcategory.name}</a>
</li>
{/foreach}
</ul>
{/if}
{/foreach}