Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
    
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
add comment

2 Answers

up vote 0 down vote accepted

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

share|improve this answer
    
That'll do it! Thanks. :) –  Dan Dec 20 '12 at 2:26
add comment

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 {
  print($wrong_date_message);
}

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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