Textpattern CMS support forum
- From: Cologne
- Registered: 2006-08-15
- Posts: 3,728
uli_if_expires_in: the last salute for expiring articles
In the How-do-I forum totoff asked how he could filter for articles that are within a certain time frame until expiry. I had some fun cooking up the least code-expensive solution, and in that case it seemed altering an existing mini plugin, Christian Sandberg’s csb_if_newer_than (I simply had to modify the maths and call another variable).
It worked in my sandbox and on totoff’s site, the support for csb_if_newer_than has apparently been anything but time/brain consuming, any inquiries to enhance the plugin will be categorically rejected, anyway, so why not make it public?
Usage (the complete help page in all its glory):
<txp:uli_if_expires_in days="30" hours="12" minutes="20"> This article will expire within the given time frame. <txp:else /> This article will not expire so soon. </txp:uli_if_expires_in>
If any attribute is left out, it is zero by default.
Get creative now and use the else part of the container for creating a two level expiry or nest some tags with different time frames for a traffic light like expiry indicator. For the logic see the example below. Have fun!
<txp:uli_if_expires_in days="7"> What gets here has 0 - 7 days until expiry. <txp:uli_if_expires_in days="6"> What gets here has 0 - 6 days until expiry. <txp:else /> What gets here will expire in 6 - 7 days exactly. </txp:uli_if_expires_in> <txp:else /> What gets here has more than 7 days until expiry. </txp:uli_if_expires_in>
Thanks to Christian Sandberg for his csb_if_newer_than.
Last edited by uli (2012-03-05 23:38:47)