If different

On this page:



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

    …contained statements…

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 Textpattern ‘article’, ‘link’, ‘comment’, and ‘file’ type Form templates.

Note: if_different can contain several HTML tags but only one Textpattern tag.


This tag has no attributes.


Example 1: Display posting time per article once per day

        <txp:posted format="%d %B %Y" />

To be used inside Textpattern ‘article’ type Form templates or an article tag container (such as article or article_custom).

Other tags used: posted.

Example 2: Build an indented list of article titles grouped by section


  • Display a list of all articles’ titles grouped by sections and ordered 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 article
  • family (section title)
  • 1st Article from family section
  • 2nd Article from family section
  • …another article
  • people (section title)
  • 1st Article from people section
  • 2nd Article from people section
  • …another article

In Textpattern Page templates, add this tag to loop through all articles from all sections:

<txp:article_custom sort="Section asc, Title asc">
            <txp:section title="1" />
        <txp:title />

The snippet above lists all article titles and renders an intermittent heading element whenever a different section is encountered while the articles loop through.

Other tags used: article_custom, section, title.


Version 4.7.2

test attribute added.

See something wrong in this document? Outdated info, a broken link, faulty code example, or whatever? Please write an issue and we’ll fix it.