Crontent Filter is an input filter that allows users to expire or enable pieces of filtered content based on timestamps, triggered by the Drupal cron job.

An example of a piece of content that Crontent would process would be the following:

Welcome to our registration page!
[expire on="11/13/2010"]Click here to sign up for the event!  Registration closes on 11/12/2010.[/expire]
[enable on="11/13/2010"]Sorry!  Registration closed for this event on 11/12/2010.  Click here to view our other events.[/enable]

Which would show the content wrapped in the expire shortcode tag until Nov 13, 2010, and hide the content wrapped in the enable tag until Nov 13, 2010.

Datetime values are parsed by the PHP function strtotime(), so any format that function accepts should work. I would strongly discourage using relative values (e.g. "next month" or "+3 weeks") as the function is called in the context of the current system timestamp when the filter is invoked.

NOTE - this filter will not work properly if Drupal's cron script is not being executed. If this becomes problematic, I might look into leveraging hook_init or hook_boot in the future to try to keep content as current as possible, but would like to avoid that for performance purposes if at all possible. Additional concerns are that hook_init doesn't get called for cached page content, and hook_boot is not guaranteed to have the filter module loaded at the time it's called, so these are not full-proof solutions either.

Credit for the idea goes to gmclelland for suggesting it on g.d.o.

Project Information

Downloads