Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I wanted to change my theme's watermark to say "Scheduled" rather than "Unpublished", so I added this to Scheduler; I hope you'd like to use it.
/**
* Implements hook_preprocess_node();
* Makes the publish_on and unpublish_on data available as theme variables.
*/
function scheduler_preprocess_node(&$variables, $hook) {
$node = $variables['node'];
$date_format = variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT);
if (isset($node->publish_on)) {
$variables['publish_on'] = date($date_format, $node->publish_on);
}
if (isset($node->unpublish_on)) {
$variables['unpublish_on'] = date($date_format, $node->unpublish_on);
}
}
Sorry, I didn't check out Scheduler so making a patch is a pain. This is strictly added code that I put at the very end of the module.
Comments
Comment #1
NancyDruFor those who want to change the theme with this:
Comment #2
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedThis is actually a really great idea. It could also be used in the theme for having a different coloring for unpublished but scheduled nodes.
Comment #3
NancyDruSure could. Many themes have an unpublished watermark, so I just extended mine (based on Zen) to have a scheduled watermark. But, yes, you could also assign a "scheduled" class to the node so that the CSS could assign a different color, or borders, etc.
Comment #4
NancyDruSmall change required for node preview.
Comment #5
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedThere is a fix for that over there: #893260: date() expects parameter 2 to be long, string given
(oh, you were faster with that... ;-)
Comment #6
NancyDruYes, this includes that fix.
Since this is new code that can be placed anywhere, I haven't done a proper patch. It works fine for me on a high-volume site.
Comment #7
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedJust thinking:
format_date()
might be a better choice overdate()
...Comment #8
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedhttp://drupal.org/cvs?commit=417094
Comment #9
NancyDruWorks for me. The format_date is more translation-friendly. I just copied code you had elsewhere, so you might want to look over your other code.