Textpattern CMS Template Tags

<txp:if_different /> container tag, 0 attributes

if_different

The if_different tag is a conditional tag and always used as an opening and closing pair, like this…

<txp:if_different>
...conditional statement with <txp:other_tag>...
</txp:if_different>

The tag will execute the contained statement when the value of the contained statement differs from the preceding value for that contained statement. Can be used in article, link, comment, and file forms.

<txp:if_different /> 2 examples

Display posting time per article once per day

Weblog

<txp:if_different>
<!-- heading - only once per day -->
<h3><txp:posted format="%d %B %Y" /></h3>
</txp:if_different>

Other tags used: posted

Build an indented list of article titles grouped by section

Intention:

  • Display a list of all articles’ titles grouped by sections and order by article title
  • Add headings from section titles to designate an article’s context
  • Sort alphabetically by section name, then by article title

Desired result:

  • about (section title)
    • 1st Article from about section
    • 2nd Article from about section
    • …another articles
  • family (section title)
    • 1st Article from family section
    • 2nd Article from family section
    • …another articles
  • people (section title)
    • 1st Article from people section
    • 2nd Article from people section
    • …another articles

In a page template, add this tag to loop through all articles from all sections:

<txp:article_custom sort="section ASC, Title ASC" form="tree" />

The contents of the tree form used by the snippet above lists all article titles and renders an intermittent heading element whenever a different section is encountered while the articles loop through:

<txp:if_different><h2><txp:section title="1" /></h2></txp:if_different>
<txp:title />

Other tags used: article_custom, section