Scheduling with Drupal: An Introduction to Slot Machine

Scheduling when content goes live on Drupal has up to this point mostly been handled on a per-node basis. For instance, the useful Scheduler module lets you schedule when a node is published/unpublished, and Workflow transitions can be scheduled as well. But what if you don’t want to have your site editors micromanage the exact publishing time for every relevant node, but instead to allow them to put content into a queue with pre-established scheduling logic? This is the purpose of the Slot Machine module, originally developed for FastCompany.com and recently released in alpha for both Drupal 5 and 6. I have proposed a DrupalCon session (vote for it!) to introduce Slot Machine to the Drupal community, but first I’ll whet your appetites with a few screenshots.

Here’s an example of a schedule filled with content:


What you see above represents what’s currently live in the schedule for this site’s Home page. (One of these schedules also exists for every channel on the site, which is constructed based on an associated taxonomy.) Each row is a slot, representing a particular feature type, and which has an associated frequency.

So, for example, currently the Home page is displaying a Bertrand Russell quote in its “Interesting Quotes” slot (associated with the Quote content type), which went live at 4:19 P.M., and has recently been live on the Community channel as well. This slot has been administered to update every 4 hours, which means at 8:19 P.M. or thereabouts — assuming cron is running (and it should be running at least once an hour for Slot Machine to work well) — the next Quote in the queue will appear in the schedule. But I could also manually remove the quote from the schedule right here, which would immediately bring in the next quote.

The Featured Blog and Featured Blog 2 slots work similarly, but they are set to update Every Morning. What does that mean? Well, Slot Machine lets you create as many frequency types as you want:


So Every Morning specifically means that the slot will grab the next node in the queue every day at 7 A.M. (One feature I hope to add if there is demand is the ability to limit frequency types to certain days of the week, or between certain business hours.)

So what does a queue look like, and how do nodes get added to it? If you click on the title of a slot, that slot’s queue will appear:


So four hours after the Bertrand Russell quote went live, the Barack Obama quote will replace it, and the Richard Stallman quote will be on deck. Notice the form elements that allow the editor to re-order the queue and remove items.

And how do things get added to the queue in the first place? There are two ways: on the node page itself, and with Slot Machine’s Featured Content Queue admin page. Adding a node via the node page is straightforward:


The greyed out checkboxes mean that this node is already in the Home and Community queues for Interesting Quotes, but we could add it to the end of another channel’s queue right there.

The Featured Content Queue tool is much more powerful, and allows the user to view all content as it is created on the site, with the ability to filter by topic (channel), content type, and keywords. This allows the editor to batch add nodes to various queues as needed:


At this point, you should have a pretty good idea how Slot Machine could handle some complex scheduling needs on sites even with a large influx of content. And making content that is live on the schedule display on your site is easy: Slot Machine provides Views integration, its own channel pages, and an API function that lets you pull content from any slot.

There’s one more thing that I haven’t addressed: what happens if there are two slots of the same feature type on the same schedule? The easy answer is that items popping off the queue will alternate into the correct slot, depending on the frequency setting. But there’s a slight more complex option as well: you can set a particular type to be “rotatable.” What does this mean? It means that the node in the first slot of a type will be rotated to the second slot of the type when the schedule is updated (rotatable types must all have the same frequency setting). So for example, you could have Today’s Feature and Yesterday’s Feature as two rotatable slots, and Slot Machine will take care of moving the nodes from one to the other appropriately.

In the example above, Featured Blog and Featured Blog 2 are rotatable. Hence, when you manually remove an item from the first slot, the user is asked whether or not they want to rotate that type into the second slot:


That’s about it for all the main features, although the devil is truly in the details. If you want to learn more about Slot Machine, download the module and give it a spin. Or vote for the “Going Live: Content Scheduling with Slot Machine” session I proposed for DrupalCon D.C. I hope to get some more people excited about this module, as it could use some testing, and it would motivate me to add some more features.

Thanks

Thanks to Katherine Bailey of Raincity Studios (sponsored by NextScreen) for removing custom FastCompany code for the initial Drupal version, and for building most of the settings pages. And thanks to Fast Company/Mansueto for sponsoring the original development. The rest of the development has been sponsored by Advomatic.

Related Projects

Node Queue Scheduler — A few years ago, merlinofchaos proposed this extension to the nodequeue module. As far as I know, his proposal was never realized.

Generic Scheduler — An issue thread for the scheduler module about making it work for generic actions.