Only echo if page attribute (date/time) has not passed

Permalink
Hi all,

I am trying to set an expiry date for access to a form and I'm thinking the easiest way will be to have a date/time page attribute, and have the code print the form if the date/time has not passed and the else statement would be something along the lines of "expiration date passed".

I'm just not sure how to achieve this with C5 7. Any help would be greatly appreciated.

Richard

 
hutman replied on at Permalink Best Answer Reply
hutman
You could achieve this by using timed permissions on the block, however if you want to use code instead you could put this around the area you are going to put your form in inside the template file

$c = Page::getCurrentPage();
if(strtotime($c->getAttribute('date_attribute_handle')) > strtotime('now')){
     //area display code
} else {
     //message if the attribute is in the past
}
mobius2000 replied on at Permalink Reply
That's fantastic, thank you very much.