Page 1 of 1

automatic element placed after specified date for each entry

Posted: Tue Dec 06, 2011 8:03 am
by electricmetaleptic
Hey all,
am hoping someone can help me think up a quick fix for this one:
we need to have each entry on our site automatically display an 'expired' text after a pre-specified date (each entry will have a different date for this). Further, I'll need to have the many hundreds of previously posted entries display this now.

Any ideas?
tx
EM

Re: automatic element placed after specified date for each e

Posted: Tue Dec 06, 2011 11:54 am
by garvinhicking
Hi!

You can add a custom entryproperty field for each entry where you can enter a date (preferably a unix timestamp, this is easiest to check later on). Give it the name "expirydate" for example

Then in your entries.tpl you can check for something like this:

Code: Select all

{if $smarty.now > $entry.properties.ep_expirydate}
<p>This entry is expired.</p>
{/if}
To also add an expired notice for older entries you could change it to:

Code: Select all

{if $smarty.now > $entry.properties.ep_expirydate OR $entry.properties.ep_expirydate == ''}
<p>This entry is expired.</p>
{/if}
Then all entries that do not have this newly added field will also be shown as expired.

Regards,
Garvin