New container tags
Textpattern 4.07 introduced many new features, one of which is the container tag capacity for various tags.
While updating one of my sites the other day I decided to update the code to utilise the new container tag format. It may be of use to others updating their own code.
In the old site, we used this code in the page template, with a call to a form for processing:
<txp:article_custom section="players" form="players_list" wraptag="ul" break="li" class="category_list" />
<txp:article_custom section="players" wraptag="ul" class="category_list" limit="20"> <li<txp:if_article_id> class="active" </txp:if_article_id>><a href="<txp:permlink />"><txp:if_article_id>» </txp:if_article_id><txp:title /></a></li> </txp:article_custom>
The above is placed in your page template. The code has been extended by adding a
class="active" to the
li item, as the code is used as a sub-menu in the sidebar, and we want our visitors to have an idea of where they are.
As you can see in the new method, there is no need for a form to process the tag attributes – this is the main difference between single and container tags. To quote TextBook:
Container tags are used when something has to be enclosed by tags instead of being replaced by them.
The above example is simple but should give you an idea of how to use the new container tags. There is less code and arguably the control over output is placed where it belongs – in the page template. Forms offer excellent functionality, but are best used in situations where you need something like a server-side include, not for processing
article tags. Thanks to the developers of Textpattern, we are now able to do this.