Textpattern tips, tutorials and code snippets

Mixing link types for navigation

Here is a small example of using the in-built Textpattern tags for developing a navigation system.

This system is useful if you need to generate a menu from various sources types – sections/categories/articles/linklists.

Enter some code on your page template

<ul class="height200">
<txp:section_list sections="news" wraptag="ul" break="li" class="" />
<txp:category_list wraptag="ul" break="li" class="" exclude="comedy" parent="Movies" section="entertainment" type="article" />
<txp:article_custom section="sports" form="article_custom_side_links" wraptag="ul" class="" break="li" sort="Title asc" limit="20" />
<txp:linklist wraptag="ul" break="li" category="External-Links" sort="linksort asc" class="" />
</ul>

Breakdown of the tags

  • The section_list tag outputs a link to the News section
  • The category_list tag outputs all article categories from the Entertainment section
  • The article_custom tag outputs 20 articles from the Sports section
  • The linklist tag outputs all links from the External Links links category

On all tags, the class="" attribute is set to empty to prevent the tags setting default class names.

An example of this menu system may be found on this page – lower right hand side.

2 Comments Comment feed

  • Maresolaris
  • 8 July 2009

Excellent! This tip (finally) gave me insight on how to employ the several link types. Thank you very much!

I use rdt_dynamenus on a few sites to create a very easy 2 dimensional navigation scheme. For example sections across the top and articles from those sections down the LH column. This works great. The following is from the plugin.

“The rdt_dynamenus plugin automagically generates section-aware menus of sections and articles and thus ensures that those menus are updated whenver new sections or articles are added to the website.”

Cheers

Phil

Add a comment

Use Textile help to style your comments