All I get under Data selector is site: and I'm dead in the water.

This is a site for an entertainment venue. I have slides controlled by a nodequeue; I want the system to remove the slides from the nodequeue once the event date has passed.

This shouldn't be so hard, right?

Well, I've been trying now for two days and I find the documentation totally impenetrable; all I get as an option in the data selector is site information, no matter what I do.

Are there any guides out there that could help me here? This shouldn't be so hard, I would think... thanks in advance to anyone who can put me out of my misery here...

Comments

bcobin created an issue. See original summary.

tr’s picture

Status: Active » Fixed

Sigh. I don't know how to help you. There is a huge amount of documentation for the Drupal 7 version of Rules. I don't know what you expect us to add here, and this issue queue isn't really the place for it, but I'll try ...

Reaction Rules consist of EVENTS, CONDITIONS, and ACTION. Specifically, you need to pose your problem in the form:

WHEN _______
IF _________
THEN _______

Where WHEN refers to the event that triggers the execution of the Rule,
IF refers to any conditions you place on the execution, and
THEN refers to the actions you take when the event happens and if the conditions are satisfied.

First, you never mention anything about WHEN. That's super important, because the variables you have available depend on the EVENT that you're reacting to. The "site" data is global and is always available. But other data depends on the event. For example, if you're reacting on "User has logged in" event then you will have access to the "user". Makes sense, right? With this event we have access to everything about the user that logged in (and nothing about any other user). But there will be no "node" data because there is no node or page associated with a user logging in. Likewise, if you're reacting to the "After saving new content" event, then you WILL have "node" data, because you've just created a node, but you won't have direct access to "user" data unless you get that data from the global current-user or from the author field of the node you just created. In Rules parlance, the data available depends on the context. You totally left out the context in your post, so I can't say what data should be available.

You need to put your problem into the above form, then many questions will answer themselves.

In your case, you're not thinking in terms of events. The event architecture used by Rules (and by programs in general) is to generate events only when things happen, then execute any piece of code that wants to take advantage of that. If the event never happens, the code never gets executed.

You seem to be thinking in terms of "polling", which means the code should keep checking, keep checking, keep checking, THEN take action if it finds something has changed. That is an extremely inefficient way to structure code.

The reason I say you're thinking of "polling" is because you say "once the event date has passed". So I interpret this as you want to execute something (from cron?) once a day or more, then loop over ALL nodes in your nodequeue and compare the current date with the date stored in the queued node. Then IF the date has passed, remove the queued node.

That's not how you should be thinking of this.

Instead, you should be using the rules_scheduler submodule. There are lots of great tutorials for this module, you should google them. Rules Scheduler allows you to schedule the execution of a Rule for a time in the future. So in your case, what I would do is:

WHEN a node is added to the nodequeue
IF the node is a "slide"
THEN schedule (using Rules Scheduler) a Rules component to be run on the event date in the future

Note the Rules component will just contain an action that removes the node in question from the nodequeue.

If you do this, then your Rule will execute once and only once - when the slide is created. Then, on the date the node needs to be removed, the Rules component will be executed once and only once to remove the node from the queue.

Again, this issue queue isn't really the place to discuss your personal application-specific needs. However, there are a LOT of examples in this issue queue (search for scheduler, make sure to look at closed issues as well). And there are a LOT of examples on the internet, including videos, which walk you through this whole process.

bcobin’s picture

Thank you so much for the detailed explanation - quite simply, the desired workflow is as follows:

1. On cron run
2. Content type=Slide

And that's as far as I get. The data selector only has "site:" available in Data selector (which is mandatory), although there is a selector for content types. I must be missing something major; I've been through the documentation over and over again and genuinely can't get to first base here.

Thanks for taking the time, though...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

bcobin’s picture

Belatedly, thanks again for the guidance. I am almost there and in revisiting this, I've discovered that the drill-down works only with jQuery Update set to Default (provided by Drupal). This is really confusing, especially for the uninitiated (like me).

I get the logic of scheduling an action at the node save event, so I'm trying to create a component to remove a node from a nodequeue after the event has passed. Where I'm stuck now is that the only available options for the Data Selector for the component are site-related (e.g., site:feed-node) and not node-related, which is what I think I would need.

I would think that I'd need to use "node" in the data selector for the "Remove node from nodequeue" action, no?

Site is https://redroomnyc.com/, BTW - I've already got Rules adding slides to the nodequeue, now I just need to figure out how they can be automatically removed so that I don't have to keep cleaning things up.

Any help greatly appreciated... thanks!

UPDATE: I finally managed to figure it out. The appropriate variables (e.g., Content, node, node and Parameter) needed to be added to the component to enable it to be scheduled from the rule (offset one day from the performance date). So now, site admins are able to add the event and have it automatically get added to the nodequeue upon creation (one action) and automatically removed at midnight on the day after the event (the component action).

Perhaps this will help someone... thanks!