Drupal 7 Scheduler Module
Share with Others
The Drupal 7 Scheduler module can be used to easily publish or unpublish nodes as a specific time. This module can be used to automate the publish of content such as blog posts and can be used to ensure your posts are published at the time you want them to be published. Using this module, you could create multiple posts and schedule them to all published, this way you don't have a lot of content created at once. If you have content that you only want to be published on your site for a limited time, you can use this module to publish the content at a specific time, and then unpublish the content later. Very simple, but very useful module.
In this episode you will learn:
- How to install and configure the Drupal 7 Scheduler module
- How to set up a content type to allow publishing or unpublishing
- How to configure content to publish at a specific time
Hello everyone and welcome to another Daily Dose of Drupal. Today we’re on Episode Number 152 and we’re going to be covering the Scheduler Module. The Scheduler Module allows you to set specific dates to publish and unpublished Nodes.
So for instance if you have blog posts and you wanted them to be published in a specific time you could use this module to schedule exactly when they need to be published and the next time Chron runs after that specific time your node will actually be published so you’ll need to make sure you have your Chron running often and we’re going to go ahead and take a look at this but before we do make sure to hop on over to codekarate.com and sign up for the newsletter if you haven’t already, it’s generally over here on the left block and now I’m already logged in or signed up and follow me on Twitter at smthomas3, also you can go ahead and follow Adam Learing on Twitter at adamlearing if you ever tweet, I don’t know if he ever really does but it might be worth to follow either way.
Let’s go ahead and get started. So we’re going to hop over to our development site here, just a simple pretty standard development site and we’re going to go ahead and turn on the scheduler module. Looks like it is already turned on I believe. So we’re going to go ahead and click … you want to make sure you enable that and then you’re also going to then need to configure it.
So once you are in the configuration page you can set the date format and you can set it to use a standard text field. We’ll start with this and we’ll also show how you can use the date pop-up calendar to make that a little easier for users to enter the date or for you to enter the date. You can specify that the user only selects the date and there’s a default time.
This is nice if you want to always publish your blog posts for instance at let’s say 8 in the morning. It will just default it to 8 o’clock and this default date would always provide the default when you’re trying to schedule when your blog post are actually published. You can add some extra info which just gets added as a description so we don’t really need that. So we go ahead and click Save and you now need to setup which content types you want scheduling to be enabled on.
So we’re going to go to our content type page and we’re going to go ahead and we’ll look at the article content type. We’re going to make sure we have this … so it’s not published by default and we’re going to click on the scheduler tab that is now going to be available once you turn on the scheduler module. Here you have two options; you can either allow scheduling or schedule publishing for the content type so that would be if you want to turn on a blog post for instance on a specific time but you can also schedule the unpublishing for a piece of content.
So let’s say you had some kind of event that was going on just for a certain amount of time or you had some kind of post you wanted to only show for specific amount of time. You can have it published at we’ll say 8 in the morning and then unpublished at 5 in the afternoon. So you can use that, we’ll go ahead and just check publishing for now, when you use … you’ll notice when you check or uncheck there are some extra options you can look at.
So the first one is to change the content creation time to match the scheduled published time. By default the contact creation is going to be whenever you first created the unpublished version of the Node since we want this to be … to make it look like it was published when it … or it was created when it was published. We’re going to go ahead and check that.
You can check this box because this will … this next box will require that the person actually schedule something. We want this to be optional because in our case we’re going to do blog post or articles we may want to actually just publish it whenever we created versus waiting but you can require that everyone gets scheduled and you can also have it create a new revision.
There’s a few advance options, so if you try to specify a publication date that’s in the past you can either display an error message, publish the content immediately or schedule the content for publication on the next Chron run. We’ll leave that at the default, unpublishing is pretty much the same options, it’s very similar so we’re not going to go over that part and when you want to display the scheduling options you can display as a vertical tab or a separate field set, we’re going to leave it at the default, we’re going to go ahead and click Save Content Type and we’re going to add a new article.
So we’re just going to create a test article, some fake content here, add an image, and now you’ll notice when we get down here is where we get to the scheduling options. So the first is just a simple text box and you can see it tells you the format that you need, it tells you the default time is 8. So leave the date blank for No Schedule Publishing. We’re going to go ahead and just put in the date here and in this case I’m going to set it for 7:12 AM which is in about 1 minute.
So I will go ahead and click … I’ll take a look and see if it’s not going to be published, so I’ll save that. It says this post is unpublished and will be published at the date that we specified it was created. If we come to the content page you’ll notice that we have this testing article 1, 2, 3 here that is not published and now we just have to wait about a few seconds here and it should be about ready to go.
One thing we’ll have to do is run Chron if you have Chron schedule to run periodically then it will go ahead and trigger as soon as the next Chron run and actually goes but since I do not have Chron set up I will need to go ahead and run Chron manually. Now assuming we let enough time go by this should have published that article which it did.
So you can see that it’s published, we come to the page and refresh you’ll notice that the submitted date has change from 7:11 to 7:12 because we check that box and tell it to update the correct date, we have our post and now it has been published. Very easy, really easy to just drop this module and then get it working. One quick thing we’re going to do is we’re going to turn on the Date Module.
So we want Date Pop-Up and Date API and Date, I’ll go ahead and click Save, once this runs we’ll go back into our Scheduler Configuration Page and we’ll select the Date Pop-Up Calendar. Here you can set the Date Pop-Up a minute increment, we’re going to set this to 15 minute increments and leave everything else the same.
Now if we go to Add Content, we go to Add Article, if we come down to the bottom scheduling options you’ll see we have a nice pop-up calendar. So we can schedule it for 10, 15 or 11:15, just notice that it goes up in 15 minute increments. So that’s really all there is to the Scheduler Module. If you want it to unpublished it would be very similar
You have just the Unpublished textbox or Unpublished Date Pop-Up Fields where you can set when you want it to be unpublished and there’s really not much more to it so go ahead and check it out, see what you think. If you have any ideas for other videos let us know and if you need help with anything you know, come to Code Karate, click the Contact link and let me know what you’re working on. Until next time, thanks for watching the Daily Dose of Drupal, see you.