Plugin: Category Parent Style
Plugins
This plugin applies a custom CSS-class to categories that have subcategories using {exp:weblog:categories}.
The Plugin uses two tags. One goes around {exp:weblog:categories}, one goes inside.
The outer one is {exp:cat_parent_style:apply class="myclass"}. It applies class="myclass" to the <li>-tag of any category that has subcategories. You may change “myclass” to any class-name you like.
The inner one is {exp:cat_parent_style:check cat_id="{category_id}"}. It checks whether the current category has subcategories and prepares it for the apply-function.
Example:
{exp:cat_parent_style:apply class="parent"}
{exp:weblog:categories weblog="default_site" style="nested"}
{exp:cat_parent_style:check cat_id="{category_id}"}
<a href="#">{category_name}</a>
{/exp:cat_parent_style:check}
{/exp:weblog:categories}
{/exp:cat_parent_style:apply}
Result:
<ul id="nav_categories" class="nav_categories">
<li class="parent"><a href="#">Our Company</a>
<ul>
<li><a href="#">Our Office</a></li>
<li><a href="#">Our Store</a></li>
<li class="parent"><a href="#">Our Fleet</a>
<ul>
<li><a href="#">Our Planes</a></li>
<li><a href="#">Our Ships</a></li>
<li><a href="#">Our Trucks</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Our Hero</a></li>
<li class="parent"><a href="#">Our Products</a>
<ul>
<li class="parent"><a href="#">Air</a>
<ul>
<li><a href="#">Lot's of Air</a></li>
<li><a href="#">More Air</a></li>
<li><a href="#">Some Air</a></li>
</ul>
</li>
<li class="parent"><a href="#">Water</a>
<ul>
<li><a href="#">Blue Water</a></li>
<li><a href="#">Red Water</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Our Services</a></li>
</ul>


Download: pi.cat_parent_style.zip


