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

merlinofchaos’s picture

Status: Active » Fixed

You 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.

chowdah’s picture

Thanks Merlin, I'll give this a whirl when I get chance. I forgot about the PHP Code rules.

Status: Fixed » Closed (fixed)
Issue tags: -date, -now, -Context, -Variant

Automatically closed -- issue fixed for 2 weeks with no activity.

kopeboy’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Issue summary: View changes
Status: Closed (fixed) » Needs work

Could 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.