Daily contents with if_different

One of the newer conditional tags added to Textpattern – if_different – allows to display date based contents in our sites without trouble.

Let say we want to display a date based header into our articles lists, which must be shown only if the day changes from one article to the next one. This can be easily achieved by placing exactly the same code Alex wrote two days ago into our article form:

<txp:if_different>
  <!-- heading - only once per day -->
  <h3><txp:posted format="%d %B %Y" /></h3>
</txp:if_different>
By: | Tags: Tips | Comments: 5

Comments

  1. This conditionnal tag will really prove useful, thanks ! Another one to add to TextBook :-)

  2. I’ve tested it. First with my own code and then with copy and paste from the example. It doesn’t work this way! The daily div contains only the first article of the day, other articles of this day will published outside this div.

  3. This conditionnal tag will really prove useful, thanks ! Another one to add to TextBook :-)

  4. But what if you want a monthly view, e.g. all posts under November? Could this be achieved without a plugin? TIA

Commenting has expired for this article.