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
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.
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.
- Create a Rule, "After saving new content"
- Add a condition of "Content is of type"
Add an "Execute PHP" action with this:
$node->publish_on = strtotime("[node:field-datefield-here]"); scheduler_node_insert($node)
Create a Rule, "After updating existing content"
- Add a condition of "Content is of type"
Add an "Execute PHP" action with this:
$node->publish_on = strtotime("[node:field-datefield-here]"); scheduler_node_update($node);
-
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?– dshahCommented Jun 26, 2012 at 18:52
-
Edited my answer with a rough Rules scenario. It's pretty rough! Commented 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.– dshahCommented 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 Commented Jun 26, 2012 at 20:21
-
Thanks a lot for your help. Definitely will go through that. I really appreciate it.– dshahCommented Jun 26, 2012 at 20:47