Forum
Website Notification Messages with Expiry
Hi all,
I was wondering if anyone had any idea how to create a notification message (or message bar) at the top of my website that would expire at a date/time that I input when I create the message in Perch?
Basically, I want to display messages like "Bank holiday on Monday. The office will be closed and will reopen on Tuesday" but I would set an expiry of 23:59:59 on Monday so that I do not constantly have to update and remove messages.
Any ideas?
Cheers!
Use
perch_content_custom()
with a filter on the start and end date fields, comparing them to the current date.You can get the current date/time with
date("Y-m-d H:i:s")
Hi Drew,
Thanks for that. I tried your suggestion but still can't get it to work. Here's what I have done so far...
That looks fine - how is it failing?
Y-m-d H:i:s
outputs the date and time like this2001-03-10 17:16:18
I don't think that can be used as avalue
tomatch
against can it?I'm guessing it would need something more like:
You'd need to save Date1 & Date2 as variables. But I'm not sure if 'filter' must be a region ID
Hi Drew,
The notification isn't showing unless the end date is at least 2 days in the future. e.g 24th viewed on the 22nd. If set to 23rd, post will not show. Start date is also not working correctly, not hiding the post until start date is set to 24th when viewed on 22nd. If set to 23rd, the post will show.
Simon, i'm not sure how to use variables yet in Perch. Would you be able to explain your above solution?
Thank you.
What does debug output for the page?
It's working now. Just realised my timezone was set to an hour early... Doh!