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 have users who can't remember that they scheduled a node. A message confirming that they did so would be very nice.
// Right before we save the node, we need to check if a "publish on" value has been set.
// If it has been set, we want to make sure the node is unpublished since it will be published at a later date
if (isset($node->publish_on) && $node->publish_on != '' && is_numeric($node->publish_on) && $node->publish_on > time()) {
$node->status = 0;
drupal_set_message(t('This post is unpublished and will be published @publish_time.', array('@publish_time' => date($date_format, $node->publish_on))), 'status', FALSE);
}
break;
That's at the end of hook_nodeapi('presave'...
Comment | File | Size | Author |
---|---|---|---|
#6 | scheduler_module_1_50_2_37-0.txt | 960 bytes | Eric-Alexander Schaefer |
Comments
Comment #1
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedI dont think we are going to include this.
Comment #2
NancyDruHow about an option? I've run into users all over the place who don't understand why their nodes aren't showing up right away. This simple change stopped most of our phone calls.
Comment #3
jonathan1055 CreditAttribution: jonathan1055 commentedHi Nancy,
I wanted the same thing, and achieved it by adding:
into my theme's hook_preprocess_node(), and
into node.tpl.php.
I know you could have figured this out too, but just thought I'd share it, in case it is any help.
Jonathan
Comment #4
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedI am curious. A user writes an article and enters a time for scheduled publishing and clicks "save". How can they forget between entering the time and klicking the save button? I don't get it.
Comment #5
NancyDruHow about they notice that some text in the body needs to be updated and by the time they get done, they have forgotten. My users do it all the time.
It can also happen when using Vertical Tabs, which I'm really getting to like, switching to another setting group, like comments, what they specified disappears; Yes, the tab says "scheduled for publishing", but they don't seem to notice that.
Comment #6
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedHere you go. Please review...
Comment #7
NancyDruLooks good. I haven't tested yet.
BTW, here's what my own submit handler does:
Comment #8
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedhttp://drupal.org/cvs?commit=398542
Comment #9
jonathan1055 CreditAttribution: jonathan1055 commentedNancy's code has the benefit of using Drupal's format_date() function, which takes care of the users selected timezone (if any) or the website's default timezone. The message which Eric's code creates just displays the time using date() which could confuse users in other timezones. Just pointing out and recording the difference, which could be addressed later if required.