Textpattern 4.0.7 outlook: dissecting the new page template

In the upcoming Textpattern 4.0.7 release, the default page template will contain a sample two-level navigation menu with the first level built by a list of sections while the second level menu is run by a list of article titles within the active section.

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.

Comments

  1. Are there subsections in 4.07?

  2. Excellent work chaps – looking forward to this! Tags as attributes is going to be particularly useful!

  3. Nice! Tags as attributes is going to be a revolution!

  4. asy_wondertag rulez… ! good job devs :D

  5. Good, I love this.

  6. This is truly great work all. I am happy happy happy :)

  7. Very nice. ETA?

  8. TXP rocks! ETA please :)

  9. Is there support for multiple cagegories?
    Is there a native tagging abilitity?
    Is there a list of expected new features?

  10. I can’t believe you still don’t have sub-sections in Txp :S I’ve tried it out in Crockery and it’s perfect, shame Crockery is crazy-horse. Can you not push for getting sub-sections in 4.0.7? It’s not like a small lil feature, it’s an essential function! This is the one thing that puts Txp way behind all other CMS’s

  11. …this, dRIZ, (an customisable urls) was the reason for me to switch. I can’t wait for subsections (and customisable urls) to be in TXP. Then finally, I no longer have to update every three weeks ;-)

  12. These two changes for 4.0.7 will be really significant. A big thanks to the developers!

    * Parser: full nesting support, allowing unlimited nesting of identical tags. * Parser: attribute values are parsed when enclosed in single quotes.

Commenting has expired for this article.