这是一个简单的问题,但在过去的两个小时里我一直在努力想办法让它发挥作用。
基本上我有一个 jquery 导航设置。我有 4 个选项卡,每个选项卡都是带有子类别的父类别。单击选项卡时,会出现一个带有子项的下拉列表。我已经完成了所有设置,但无法根据选择的任何类别将一类“活动”添加到子类别中。
除非我已经空白并且这是就在我眼前,否则我找不到明显的方法来做到这一点。我认为问题是,我没有硬编码导航链接,因为客户希望自己管理这些链接,所以我动态显示了类别,向其中添加“if”语句就是将 if 语句添加到所有类别,因此该类被添加到所有子选项卡中。
这是我的代码:
<div id="tabbed-cats">
{exp:channel:entries channel="product"}
<ul class="tabs">
<li class="nav-one"><a href="#bathroom" {categories}{if category_id == "1"}class="current"{/if}{/categories}>Bathroom</a></li>
<li class="nav-two"><a href="#homecare" {categories}{if category_id == "2"}class="current"{/if}{/categories}>Homecare</a></li>
<li class="nav-three"><a href="#transfer-equipment" {categories}{if category_id == "3"}class="current"{/if}{/categories}>Transfer Equipment</a></li>
<li class="nav-four last"><a href="#mobility" {categories}{if category_id == "4"}class="current"{/if}{/categories}>Mobility</a></li>
</ul>
{/exp:channel:entries}
<div class="list-wrap">
{exp:channel:entries channel="product"}
<ul id="bathroom" {categories}{if category_id == "2" OR category_id == "3" OR category_id == "4"}class="hide"{/if}{/categories}>
{exp:child_categories channel="product" parent="1" category_group="1" show_empty="yes"}
{child_category_start}
<li><a {categories}{if category_id == "5"}class="active"{/if}{/categories} href="{path='products/category/{child_category_url_title}'}">{child_category_name}</a></li>
{child_category_end}
{/exp:child_categories}
</ul>
{/exp:channel:entries}
{exp:channel:entries channel="product"}
<ul id="homecare" {categories}{if category_id == "1" OR category_id == "3" OR category_id == "4"}class="hide"{/if}{/categories}>
{exp:child_categories channel="product" parent="2" category_group="1" show_empty="yes"}
{child_category_start}
<li><a {categories}{if category_id == "6"}class="active"{/if}{/categories} href="{path='products/category/{child_category_url_title}'}">{child_category_name}</a></li>
{child_category_end}
{/exp:child_categories}
</ul>
{/exp:channel:entries}
{exp:channel:entries channel="product"}
<ul id="transfer-equipment" {categories}{if category_id == "1" OR category_id == "2" OR category_id == "4"}class="hide"{/if}{/categories}>
{exp:child_categories channel="product" parent="3" category_group="1" show_empty="yes"}
{child_category_start}
<li><a {categories}{if category_id == "8"}class="active"{/if}{/categories} href="{path='products/category/{child_category_url_title}'}">{child_category_name}</a></li>
{child_category_end}
{/exp:child_categories}
</ul>
{/exp:channel:entries}
{exp:channel:entries channel="product"}
<ul id="mobility" {categories}{if category_id == "1" OR category_id == "2" OR category_id == "3"}class="hide"{/if}{/categories}>
{exp:child_categories channel="product" parent="4" category_group="1" show_empty="yes"}
{child_category_start}
<li><a {categories}{if category_id == "7"}class="active"{/if}{/categories} href="{path='products/category/{child_category_url_title}'}">{child_category_name}</a></li>
{child_category_end}
{/exp:child_categories}
</ul>
{/exp:channel:entries}
</div><!-- END LIST WRAP -->
<br style="clear:both;" />