The Serendipity Handbook

You can now read the (german) handbook here: PDF - https://github.com/s9y/Book (LaTeX source).

Forum-Information

Before posting about errors, make sure that the answer cannot already be found in our FAQ or by searching this forum!
Posting is restricted to registered users (registering is free and simple!) due to recent spam attacks. When having trouble with this board, contact garvin(-at)s9y(-dot)org.

Board index Themes automatic element placed after specified date for each entry

Skinning and designing Serendipity (CSS, HTML, Smarty)
electricmetaleptic
 
Posts: 1
Joined: Tue Dec 06, 2011 8:55 am

Postby electricmetaleptic » Tue Dec 06, 2011 9:03 am

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

User avatar
garvinhicking
Core Developer
 
Posts: 28954
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Tue Dec 06, 2011 12:54 pm

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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/



Return to Themes

Who is online

Users browsing this forum: No registered users and 2 guests