Texpattern context demo

Current global context
SectionArticle
context_demo139

Pagination context

Yes, even page number is a context.

“How do I make article_custom paginate?” is one of Txp’s classic FAQs. article_custom is not context-sensitive. Pagination is a context. Ergo, article_custom does not paginate.

(As shown in the date-context examples, you can make article_custom partly context-sensitive with some trickery. But this works much better with date than with pagination.)

As of Txp 4.3.0, images, linklist, and file_download_list can all be paginated. Keep in mind that all these tags (and article, of course) use the same pagination context. If you want to mix different paginated lists in one context, be sure to give each list the same limit (and pageby, for all the tags other than article) value.

Don’t combine pagination with random sorting — the list gets resorted on every page load.

Pagination context is strictly global. It is more than just the the pg parameter, though: it also includes the total number of pages and items in the set. Total pages and items are calculated by any of the pagination-senstive tags listed above, but only by the first such tag on the page. This can lead to surprises. All in all it is best to avoid trying to mix paginated lists in the same context.

newer and older are Txp’s core tags for navigating paginated lists. They get my vote for worst-named tags: what they actually do is return the previous or next page, respectively. This will only be actual newer or older items if the list is sorted in descending date order. They preserve most aspects of global context, but not global article or image context. This makes sense, since those contexts represent individual items, not lists.

However you can still force Txp to paginate a list from within global article or image context, by cobbling together the URLs. It’s a rudimentary sort of pagination but might be useful occasionally.

This code:

<txp:permlink>Page 1</txp:permlink> | 
<a href="<txp:permlink />?pg=2">Page 2</a>
<br />
<txp:images category="wildflowers, watching" limit="6" pageby="6" break="" />

produces this output:

Page 1 | Page 2