Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-03-02 15:55:44

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,311

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?

Download uli_if_expires_in

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)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#2 2012-03-03 13:05:20

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,311

Re: uli_if_expires_in: the last salute for expiring articles

No surrounding <txp:if_expires> necessary any longer, penny dropped.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB