I have an event content type with a date field. Is there a rule I can create that will display a system message to the user that "This event is now over." based on comparing the current date and the date in the date field?


enter image description here

2 Answers 2


Rules can be used for this. Your message will be displayed using drupal_set_message()

Starting at the Admin screen;

  1. Click through Configuration > Rules > Add New Rule
  2. Give it a name and select Content is viewed in React on event. Click Save.
  3. Under Conditions click Add condition
    1. Select Data > Data comparison
    2. Select node:type and click Save
    3. Fill in for your content type and save
  4. Under Conditions click Add condition (again)
    1. Select Entities > Entity has field
    2. Data Selector should have node
    3. Field should have the field you're wanting to check. This should be a date field
  5. Under Conditions click Add condition (again)
    1. Select Data > Data comparison
    2. In Data Selector chose your field. Mine was node:field-end-date
    3. Click Continue.
    4. Under Operator select is lower than
    5. Under Data value select site:current-date
    6. Click Save
  6. Under Actions click Add action
    1. Select the System > Show a message on the site entry.
    2. Enter your Message, select the Message type (this is the drupal_set_message() status), untick Repeat message and click Save
  7. Browse to your expired content to see your message.
  • This worked well Thanks. Any thought on how to accommodate for a repeating event. One that starts and ends on one day and is repeated every week? Any way to compare the last date? Commented Dec 20, 2012 at 19:36
  • Are you meaning that the one node is a repeating event? i.e. there's not multiple nodes? I'm not sure. I was fortunate enough to have this sort of situation on the project I'm currently working on. But each node only has one date.
    – Gold
    Commented Dec 20, 2012 at 19:50
  • correct. one node using date repeats. Commented Dec 20, 2012 at 19:51
  • That's getting messy. :/ I imagine you'll need to dig around in some code to get that working. I would start by exploring the options in the date comparison though.
    – Gold
    Commented Dec 20, 2012 at 19:53
  • When I add my date field to the data comparison, I see 4 options even though I only have one date field for the entire site. THis might have something to do with it? I have updated my question above with a screenshot to further clarify what I see. Commented Dec 20, 2012 at 19:57

Your question is vague. What is a "message" to the user, a pop-up window ? a fake field you display above the other fields if the date is passed ?

The easiest thing for you to do without coding a custom module is probably using Display Suite to create a custom_field in your content type. Use PHP to set the string value of the message if the date has passed as the field body. Or if the date has passed then call drupal_set_message('Event has already occurred'); Or else return an empty string.

If you want a popup-window you can probably find a suitable module that shows a popup window from this popup module comparison matrix.

  • Sorry for the confusion. It would be a system message. I have edited my question accordingly. Commented Dec 19, 2012 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.