1

I have a Drupal 7 blog where I write content in advance and publish it using the Scheduler module. I'd like to be able to write a rule to send me an email when the site has published the last scheduled node available. I have a View set up which lists all the scheduled nodes, but I can't figure out how to get the result count of that view into the condition of a rule. I've got Views Bulk Operations and Views Rules installed, but I can't figure out how to use either of those how I need to.

1

You can make this work also by using Rules in combination with the Views Bulk Operations module, as further detailed below.

Step 1

Use the Views Bulk Operations module to create a view of all your "nodes to be published" (as in your question), in which you add a VBO field to it. Simply include a field like nid for each node (no need for any other fields). Just make sure you get exactly 1 row for each node you want to take into consideration.

Step 2

Create a Rules Component with a Rules Condition "Check number of results returned by a VBO view". And select the VBO view created in the previous step. If the number of results is below 1, then perform a Rules Action (in that Rules Component) to trigger your eMail.

Step 3

Create a Rule like so:

  • Use some relevant Rules Event related to those nodes to be published.
  • Don't use any Rules Conditions (there is no need for them in this rule).
  • Perform a Rules Action to execute the Rules Component from Step 2.

If you cannot think of any relevant Rules Event that would fit for such rule, then just create a Rules Component which has (only) 2 Rules Actions:

  • Perform a Rules Action to execute the Rules Component from Step 2.
  • Reschedule this (extra) Rules Component itself, eg after X mins or hours

Then trigger the very first execution of this Rules Component using the Rules UI.

Done!

  • Ah! I was so close; I just didn't have any VBO fields on that view. Thanks! – Cassandra Gelvin Jan 28 '18 at 21:24
0

Since you also have the Views Rules module enabled, you could use a completely different approach like so also:

  • Before starting the Views Rules loop (Rules Action) to iterate over all results of the view, define some boolean (or integer) variable which you set (initial value) to FALSE (or 0).
  • Within each iteration of your Views Rules loop, set the value of the variable to TRUE (or 1).
  • After the Views Rules loop completed, use the Conditional Rules module to check the value of your extra variable: if it is still FALSE (or 0), you know there were no nodes to be processed, so that's when you want to send that eMail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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