I want to know if I can hide the values of a date field if the values are older than a certain time. The website is built with Drupal 7, and Display Suite.

  • I don't think Rules are the tool you need. Why do you ask specifically about Rules?
    – Mołot
    Apr 11 '14 at 14:12

Use the Conditional Fields module.

Conditional Fields allows you to manage sets of dependencies between fields. When a field is “dependent”, it will only be available for editing and displayed if the state of the “dependee” field matches the right condition.

  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – mpdonadio
    Apr 12 '14 at 1:01
  • Hello MPD. No offense, but if someone knows Drupal slightly, then the link to the Conditional Field's module page is more than enough to get him/her started. The concept is simple and quite straight forward and the module's page has a link to the module's documentation page. Furthermore, there are numbers of contributed modules that integrates with Conditional Fields including the Date module. Whether of not the answer has enough reference, let Ghost be the judge.
    – asiby
    Apr 12 '14 at 14:15
  • The thing is, link-only answers are considered bad ones. This isn't a unique policy here; it is pretty much the same at all Stack Exchange sites. Links are acceptable (and encouraged), but they should support an answers, and not just be the answer. Other sites will delete them outright. Answers needs to be able to stand on their own.
    – mpdonadio
    Apr 13 '14 at 0:50
  • We tolerate them somewhat, but at a minimum when recommending a module, we like people to quote the relevant portion from the project page (like how @FreeRadical edited in). Ideally, some additional information on how it will solve the OPs question would be nice, it it can't be gleaned from the excerpt.
    – mpdonadio
    Apr 13 '14 at 0:50
  • Can you explain how I can do that with the Conditional Fields module as I haven't used it before.
    – Daust
    Apr 13 '14 at 1:08

The field formatter conditions module allows you to configure your field formatters with various conditions.

One of the included conditions is "Hide date field if from/to has expired", which should cover your requirements.

The module also has rules integration, but that shouldn't be needed for your requirements.

[EDIT] Actually it only allows working based on current time, not an arbitrary time.

  • Note that the module needs some work on timezone handling for fields where you are displaying the date in a different timezone than UTC. See drupal.org/node/2240123
    – rooby
    Apr 14 '14 at 2:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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