This is how the snippet looks like:

<txp:section_list default_title='<txp:text item="home" />' include_default="1" wraptag="ul" break="li">
    <txp:if_section name='<txp:section />'>&raquo;</txp:if_section>
    <txp:section link="1" title="1" />
        <txp:if_section name='<txp:section />'>
            <txp:article_custom  section='<txp:section />' wraptag="ul" break="li">
                <txp:if_article_id>&rsaquo;</txp:if_article_id>
            <txp:permlink><txp:title /></txp:permlink>
        </txp:article_custom>
    </txp:if_section>
</txp:section_list>

As most of the stock pages’ code, this isn’t meant to be of utter beauty or a means to all ends, but rather as a live example of how one could take advantage of a few tags’ capabilities.

Dissecting the menu shows the application of features new to Textpattern 4.0.7:

  • Container capabilities for a wider range of tags
  • Tags as attributes
  • Context sensitive behaviour of the <txp:section /> tag

Container capabilities

With Textpattern 4.0.7, most of the intrinsic tags which produce list of site elements like articles, categories, links, or sections can either act as a container tag or receive a form attribute as a boilerplate for a single item’s markup:

  • <txp:article />, <txp:article_custom />
  • <txp:section_list />
  • <txp:recent_comments />
  • …and some more. In the final release, HISTORY.txt will contain a definite list of all affected tags.

The menu’s first level uses <txp:section_list>...</txp:section_list> to produce an <ul> element with links to all listed sections.

Context sensitivity

The next line compares the current section name with the section from the page’s URL to conditionally place a little indicator arrow next to the active link:

<txp:if_section name='<txp:section />'>&raquo;</txp:if_section>

Single quotes around <txp:section /> are used to force attribute parsing and thus feed the actual section name into <txp:if_section>.

Now we finally link to the menu item:

<txp:section link="1" title="1" />

Note: <txp:section /> is part of a section list, so context sensitivity applies here as well, and the menu link will point to the list’s current section.

Ubiquitous break and wraptag attributes

Enter level two. The second menu level applies the principles of the first level on an article list built by <txp:article_custom> with its newly acquired container tag powers. <txp:if_article_id> checks for the “current” article match and prepends a tiny angle to indicate the active choice.

<txp:if_section name='<txp:section />'>
    <txp:article_custom  section='<txp:section />' wraptag="ul" break="li">
        <txp:if_article_id>&rsaquo;</txp:if_article_id>
        <txp:permlink><txp:title /></txp:permlink>
    </txp:article_custom>
</txp:if_section>

Benefits and disadvantages

As these new opportunities pile up, so do performance considerations.

Inline markup embraced by container tags is technically equivalent to a separate form passed into a tag as an attribute, and all upgraded tags will accept both methods for specifying their output markup.

During laboratory tests, Ruud found no significant differences between both methods: The performance cost of loading a form is approximately equivalent to the additional parsing time required for inline markup, so you can adopt the most appropriate method and needn’t care about speed implications.