By Paul
08/20/11 (Edited 09/12/11)
Sometimes, you want category navigation to be present on every page of a site. This is often does as a menu of categories on the left side of each page where the current category is highlighted. The simple case of this for a site with just top level categories could use this toplist:
<ul>
<!-- BEGIN TOPLIST -->
<CONFIG>categories[,]name[,]100[,]ascending[,]parent=0</CONFIG>
<li><a href="{CATURL}">{CATNAME}</a></li>
<!-- END TOPLIST -->
</ul>
<!-- BEGIN TOPLIST -->
<CONFIG>categories[,]name[,]100[,]ascending[,]parent=0</CONFIG>
<li><a href="{CATURL}">{CATNAME}</a></li>
<!-- END TOPLIST -->
</ul>
If your site has subcategories though, you may want those included in the menu. Here's a rough example:
<table width="200">
<!-- BEGIN TOPLIST -->
<CONFIG>categories[,]name[,]100[,]descending[,]parent=0</CONFIG>
<tr>
<td><IF {THISCATID} is {CATID}>-<ELSE><a href="{CATURL}">+</a></IF></TD>
<td>
<IF {THISCATID} is {CATID}>{CATNAME}<ELSE><a href="{CATURL}">{CATNAME}</a></IF>
</TD>
</tr>
<IF {THISCATTOPLEVELID} is {CATID} and {CATNUMSUB}>
<!-- BEGIN SUBSUB -->
<tr>
<IF {THISCATID} is {CATID}>
<td> </td>
<td>{CATNAME}</td>
<ELSE>
<td> </td>
<td><a href="{CATURL}">{CATNAME}</a></td>
</IF>
</tr>
<!-- END SUBSUB -->
</IF>
<!-- END TOPLIST -->
</table>
<!-- BEGIN TOPLIST -->
<CONFIG>categories[,]name[,]100[,]descending[,]parent=0</CONFIG>
<tr>
<td><IF {THISCATID} is {CATID}>-<ELSE><a href="{CATURL}">+</a></IF></TD>
<td>
<IF {THISCATID} is {CATID}>{CATNAME}<ELSE><a href="{CATURL}">{CATNAME}</a></IF>
</TD>
</tr>
<IF {THISCATTOPLEVELID} is {CATID} and {CATNUMSUB}>
<!-- BEGIN SUBSUB -->
<tr>
<IF {THISCATID} is {CATID}>
<td> </td>
<td>{CATNAME}</td>
<ELSE>
<td> </td>
<td><a href="{CATURL}">{CATNAME}</a></td>
</IF>
</tr>
<!-- END SUBSUB -->
</IF>
<!-- END TOPLIST -->
</table>
Place that in your wrapper template and it will display the categories and their subcategories, with a + next to the collapsed (non-selected) top categories and a - next to the selected top level category, and the current category and subcategory delinked.




