I'd like to place a small overlay on my video called "New". So I downloaded the date module and added a date field to my video content type.

Anyone know if its possible to then output the date field (which I can style with CSS) only for a certain period of time like a week or two? After a set date the field would not be output.

Thanks guys!

Update: I have found a module called fieldscheduler that will schedule a field, but I cannot schedule a specific node, only all nodes that use that field. So close!

  • How are you displaying it now? Is it on a node page? What does the template file code for this field look like? – beth Dec 15 '12 at 15:06
  • @beth yes, it is a field in a custom content type that outputs the date. In my code the date field is output like this: <?php print render($content['field_date']); ?>. I think I need a simple php script that looks at the date value and if its before then display something and if after, then not. I'm just not well versed in PHP to do so. – Dan Dec 15 '12 at 16:44
  • Aw, well then that's more of a PHP question than a Drupal question, but I'll try to answer. – beth Dec 17 '12 at 15:34

Field Formatter Conditions should do what you want with perhaps a little tweaking/Rules manipulation.

|improve this answer|||||

I don't know what format your date field uses so you'll have to adjust for that, but something along the lines of

if(($content['field_date'] >= $first_date) && ($content['field_date'] <= $second_date)) {
  print render($content['field_date');
} else {

...where $first_date and $second_date are the beginning and end of the date window for which you want to display the field, and $wrong_date_message is whatever you want to show up there instead when the field isn't displayed.

For more information about date formats in PHP, check out http://php.net/date.

|improve this answer|||||

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.