Using Textpattern CMS `newer` and `older` tags

admin-ajaxThis is part four of my five part series on Textpattern CMS navigational tags. I’m going to follow the format of the previous posts and explain about a couple of Textpattern tags, their attributes and typical usage. Getting to grips with tags will make your Textpattern experience more fulfilling and perhaps even a heck of a lot easier when you grasp the fundamentals of how they work. In this article, I’m going to cover two tags:

  • `newer`
  • `older`

Both of these tags have been designed and implemented so that they can be wheeled out as single or container tags, which makes them particularly helpful when your Textpattern sites increase in complexity and scope.

The `newer` and `older` tags share the same three attributes:

  • escape=”html or unset” (default: html)
  • showalways=”boolean” (default: 0, unset)
  • title=”HTML title attribute” (default: unset)

In an earlier post, I explained how you should be careful when using `showalways`. With the `newer` and `older` tags, if there’re no newer or older articles to show, nothing will be displayed. This can lead to confusing UI problems, so avoid it where possible.

The usage examples are functional rather than exciting. Here’s how to make an image into a hyperlink to the older article in the list:

<a href="<txp:older />"><img src="older.png" id="older-image" /></a>

That’s the single tag at work: it builds the plain URL and the other stuff wrapped around it switches it to a hyperlink. Want to see a container example? Certainly:


Jumping back to the `showalways` attribute and the concept of a check for whether newer or older articles exist in a list, the structure of the `newer` and `older` tags is important. Consider these two examples:

<a href="<txp:older />"><img src="older.png" id="older-image" /></a>
<txp:older><img src="older.png" id="older-image" /></txp:older>

In the first of the two, the image will be displayed whether there are older articles or not (read: confusing UI), whereas the second will do a sanity check first – if there’s no older articles, the image will not be displayed. Clever stuff.

And, well, that’s about it. Experiment with what works best for your site, but be aware of the `showalways` pitfalls.

Next time: `section` and `section_list`.

Looking for quality Textpattern Hosting? Look no further than Arvixe Web Hosting and use coupon TEXTPATTERN for 20% off your first invoice!

Tags: , , , , , , , , , | Posted under Textpattern | RSS 2.0

Author Spotlight

Pete Cooper

Pete Cooper has been using Textpattern since 2005. Textpattern is his preferred CMS weapon of choice. Its logical and flexible approach to content management makes Pete happy, as does its lightweight core and helpful user community. Pete's website - - runs on top of Textpattern and chronicles his day-to-day experiences from his home near the Atlantic in north Cornwall, United Kingdom.

Leave a Reply

Your email address will not be published. Required fields are marked *