0

I have a content type article with a field date.

I am trying to fire a variant from Page Manager by defining a selection rule based on a date field.

What I am trying to do is applying this variant when

  • the node type is article
  • field date, start date < now < field date, end date

I can define the first condition but I can't figure out how to make a condition based on a date. Is it possible or not? I couldn't find more information about this.

Thanks

Constantin
  • 8,721
  • 13
  • 75
  • 126
  • Could you show us how you would define the first condition? Questions about code should contain code if possible - that will make it easier to understand and solve the problem. – Constantin Dec 10 '13 at 11:33
  • The first condition is simply defined by adding a selection rule on Node: type. The problem is with the second condition: field date, start date < now < field date, end date. If I try to add a new Selection rule on Node article: Date field I can specify what should be the precise value of the date, but can't make a condition with "in between". – user3065518 Dec 10 '13 at 11:58
  • I couldn't find a way to make this work, so in the end I wrote a custom module without using Page Manager. If somebody has a solution though please let me know. – user3065518 Dec 11 '13 at 08:19

1 Answers1

0

I managed to do this finally by writing a PHP Code Selection Rule.

I got from the exposed $contexts variable the start and end values for date field and I wrote a simple condition to check if "now" is in between the two dates.

Beware that the dates are stored in UTC format in the field and your site/users might be in a different timezone.