3

我无法解决如何在 ExpressionEngine中创建具有GWcode 类别的动态菜单。我希望菜单仅针对当前{segment_2}(父)类别和其余父类别的深度保持为 1。

例如,如果 url 是: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 &amp; 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>
4

1 回答 1

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}
于 2012-11-08T16:05:06.703 回答