Is there a way to create a variant that will use a date/time context to determine what variant should be published? I would like to create a panels page with two variants to serve as my home page and would like to tell it to publish one variant for the weekend (Thursday afternoon -Sunday night with a pane pertaining to "This Weekend" ) and a default variant for the rest of the time (Monday - Thursday afternoon).
Comments
Comment #1
merlinofchaos commentedYou could do this with a PHP Code access rule.
You'd write a snippet of PHP which uses time() to get the current time and format_date() (or just date() depending on if you care if the user's timezone is respected) and compare and return true if it's within a range or false if not.
Comment #2
chowdah commentedThanks Merlin, I'll give this a whirl when I get chance. I forgot about the PHP Code rules.
Comment #5
kopeboyCould you provide us with an example on how you did this?
Let's say I have a field_date on the node I am overriding using Panel page "Node template" /node/%node
I want to select a "Past event" variant for the Event node bundle when it's field_date start value is past.