Textpattern tips, tutorials and code snippets

Nested category and article menu with consistent URLs

If anyone ever wanted to have a nested menu with consistent urls containing categories, sub-categories and articles here’s the code:

<ul id="menu">
<li><a href="<txp:site_url />"><txp:site_name /></a></li>
<txp:category_list children="0" break="li">
<txp:category title="1" link="1" section="default" />
<txp:article_custom category='<txp:category />' break="li" wraptag="ul" limit="999">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
<txp:category_list parent='<txp:category />' exclude='<txp:category />' break="" wraptag="ul">
<li><txp:category title="1" link="1" section="default" />
<txp:article_custom category='<txp:category />' wraptag="ul" limit="999">
<li><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom></li>
</txp:category_list>
</txp:category_list>
</ul>

More information on the forum thread.

Use Textile help to style your comments