我无法解决如何在ExpressionEngine中使用GWcode categories创建动态菜单的问题。我希望菜单仅针对当前{segment_2}
(父级)类别以及其他父类别进行一定深度,以保持深度为1。
例如,如果网址是:domain.com/products/medical-tables-cabinets/eta-classic-series/,则会输出:
<ul class="nav-menu">
<li><a href="#">Power Tables</a></li>
<li class="active submenu"><a href="#">Medical Tables & Cabinets</a>
<ul class="nav-submenu">
<li><a href="#">ETA Alpha Series</a></li>
<li class="active submenu"><a href="#">ETA Classic Series</a>
<ul class="nav-submenu">
<li><a href="#">Entry A</a></li>
<li><a href="#">Entry B</a></li>
<li><a href="#">Entry C</a></li>
</ul>
</li>
<li><a href="#">Style Line Cabinet Models</a></li>
<li><a href="#">Echo Image Series</a></li>
<li><a href="#">Bariatric Series</a></li>
<li><a href="#">Family Practice</a></li>
<li><a href="#">Treatment & Bedside Cabinets</a></li>
<li><a href="#">Managed Care Quick Cabinets</a></li>
<li><a href="#">Recovery Couches</a></li>
</ul>
</li>
<li><a href="#">Pediatric Equipment</a></li>
<li><a href="#">Medical Seating</a></li>
<li><a href="#">Blood Drawing Chairs</a></li>
<li><a href="#">Tubular Steel & Accessories</a></li>
<li><a href="#">Physical Therapy Equipment</a></li>
<li><a href="#">Kangoo by Clinton</a></li>
<li><a href="#">Training Room Furnishings</a></li>
<li><a href="#">Index by Model #</a></li>
<li><a href="#">Clinton-Eco Tables</a></li>
</ul>
答案 0 :(得分:2)
我得到了它的工作,但我仍然需要更深入一点。这是基本概念:
{exp:gwcode_categories
channel="products"
style="linear"
}
{if depth1_start AND segment_2 != cat_url_title}
<li><a href="/products/{complete_path}">{cat_name}</a></li>
{/if}
{if depth1_start AND segment_2 == cat_url_title}
<li class="active submenu"><a href="/products/{complete_path}">{cat_name}</a>
<ul class="nav-submenu">
{/if}
{if depth == 2 AND segment_2 == parent_url_title}
<li{if segment_3 == cat_url_title} class="active"{/if}><a href="/products/{complete_path}">{cat_name}</a></li>
{/if}
{if depth1_end AND segment_2 == parent_url_title}
</ul>
</li>
{/if}
{/exp:gwcode_categories}