3

I have a Date field in a custom content type in Drupal 7. I would want to control the publishing of the content instance based on that particular Date. I want the job of the Scheduler module but have it as a field in my content type and access it accordingly. Is there a way to do it using triggers or Rules? Any thoughts on this would be really useful.

1 Answer 1

3

There is a patch to make the Scheduler "Publish On" date render itself as a field: http://drupal.org/node/1203958

This presents a new Checkbox called "Show Scheduling options in vertical tabs", which you can uncheck to display as a field. Then you give it some weight so it shows up where you want it to.

Scheduler Configuration Scheduler rendered field

It's been working for me in production for a month or so.

EDIT: Here's a better way to make this happen with both Scheduler and Rules.

  1. Create a Rule, "After saving new content"
  2. Add a condition of "Content is of type"
  3. Add an "Execute PHP" action with this:

    $node->publish_on = strtotime("[node:field-datefield-here]"); scheduler_node_insert($node)

  4. Create a Rule, "After updating existing content"

  5. Add a condition of "Content is of type"
  6. Add an "Execute PHP" action with this:

    $node->publish_on = strtotime("[node:field-datefield-here]"); scheduler_node_update($node);

13
  • Thanks a lot for that. I will definitely look at that right away. But I think we should be able to do it using Rules as well. Is there a way to do it using Rules and triggers?
    – dshah
    Jun 26, 2012 at 18:52
  • Edited my answer with a rough Rules scenario. It's pretty rough! Jun 26, 2012 at 19:39
  • Perfect. I would love it if I can use Scheduler module but I can't seem to get the patch working and also would it just show up as a field type? How do I go about it? Any screen shots to help me here would be so much appreciated.
    – dshah
    Jun 26, 2012 at 19:49
  • Make sure you're using the 7.x-1.x-dev version of Scheduler. Here is a link to apply a patch: stackoverflow.com/questions/5577944/… Or from Drupal.org: drupal.org/patch/apply Jun 26, 2012 at 20:21
  • Thanks a lot for your help. Definitely will go through that. I really appreciate it.
    – dshah
    Jun 26, 2012 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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