Texpattern context demo
Section | Article |
---|---|
context_demo | 150 |
The section tag
There’s more to the section
tag than appears at first glance. It seems quite simple, returning either a named section, or the section from the current context. A closer look reveals numerous options for how to display the section:
- section name (i.e., URL segment)
- section title
- section landing page URL
- hyperlink to the section landing page
- name as link text
- title as link text
- tag contents as link text
Still, these options are easy to understand. But what is the current context? Section context has three layers, in descending order of priority:
- local section context from
section_list
- section from local article context
- global section context
Let’s put section
through its paces.
This code:
<ul>
<li>
Current section: <b><txp:section /></b><br />
(from global section context)
</li>
<txp:section_list sections="info">
<li>
Current section: <b><txp:section /></b><br />
(from <code>section_list</code> context)
</li>
<txp:article_custom section="txp" limit="1">
<li>
Current section: <b><txp:section /></b><br />
(still from <code>section_list</code> context,
despite local article context)
</li>
</txp:article_custom>
</txp:section_list>
<txp:article_custom section="txp" limit="1">
<li>
Current section: <b><txp:section /></b><br />
(now from local article context)
</li>
</txp:article_custom>
</ul>
produces this output:
-
Current section: context_demo
(from global section context) -
Current section: info
(fromsection_list
context) -
Current section: info
(still fromsection_list
context, despite local article context) -
Current section: txp
(now from local article context)