Texpattern context demo

Current global context

Textpattern context demo

This demo gives you an inside look at how tags and contexts interact. The current global context is shown at the top of every page. Each page includes at least one code example, shown alongside the actual output from that code, so you can see how tags respond to context. It is not exhaustive: some context elements aren’t included (yet). Work through the examples starting from the top of the sidebar.

Simple global context — section only

Note: the explanatory text follows the convention of presenting Txp tags by name, in a monospace font, and without tag brackets or the txp: prefix. I.e., <txp:article /> is shown as article. Tag attribute names are shown in the same monospace font. (The actual code samples are real working code, with all tags written out fully.)

As discussed in Parsing global context, the minimum global context is section context only. This page is just such a context, as the “Current global context” table above shows. That is, this is the front page (or landing page) of the “context_demo” section.

The example below shows how the article tag responds to this context. article always limits its results to articles belonging to the current section. Lacking any other global context elements, article returns all articles belonging to the section, subject to the limit and offset attributes.

You may want to come back to this page later, after you’ve read more about how article works. Start with Global vs. local.

This code:

<txp:article wraptag="ul" break="li" sort="Posted asc" limit="4">
	<txp:permlink><txp:permlink /></txp:permlink>

produces this output: