Article Navigation Tags · 28.03.04

Navigating single articles

TXP provides us two groups of tags to display links to the previous and next article to the current one.

You can create a link to the next article using the container tag <txp:link_to_next></txp:link_to_next> and placing the text you want to show for the link inside, for example, “Next article”; (original, eh?).

If you want to show the next article title on this link, you can place inside the previous tag <txp:next_title />.
This is the default option when you use the TXP TAG BUILDER ASSISTANT, click on the “Link to the next article” link and, then click on the “Build Tag” submit button.

At the same way, you can combine <txp:link_to_prev></txp:link_to_prev> and <txp:prev_title /> to build your custom links to previous articles.

Navigating multiple articles pages

If you want to provide this kinda of navigation links for pages where multiple articles are listed, you must use the tags <txp:newer></txp:newer> for pages which are sorted after the current one, and <txp:older></txp:older> for those ones that are place previously, in agreement to the article sorting criteria.

Pages of multiple articles are section and category pages and, of course, your main page.

So, if we have tags intended to be used only with single articles, and the equivalent ones for multiple pages, how can we use them on the same template?.

Conditionals tags to the rescue. Let’s have a look to the next example:

Paginating articles and pages

<p><txp:link_to_prev><txp:prev_title /></txp:link_to_prev> |
<txp:link_to_next><txp:next_title /></txp:link_to_next></p>

<p><txp:older>Prev Page</txp:older> |
<txp:newer>Next Page</txp:newer></p>

One consideration about the <txp:newer> and <txp:older> tags. As of γ1.17b, it seems these tags works only if you place them in your template after the <txp:article> tag. But don’t show nothing if you place them previously.

If you want to know more about Conditional tags, check their [future] section on this manual.

* * *

« Attributes | Site Navigation Tags »