2

Overall goal: If a node has not been commented on in a given time frame, send an email.

How it could possibly be done: Have Rules look at the last time a comment was posted when cron runs. Then do a data comparison of that unit (current time - last comment posted time) to see if its greater than the time frame assigned to the node (ex: hours). If so, send email.

Is this approach correct? I am struggling to get the Rule to work if it is.

7
  • is the given time frame, ie: check every 20 min, or is it a 1 time thing, ie: after 2 days?
    – No Sssweat
    Commented Dec 27, 2015 at 23:35
  • Checking every 20 minutes
    – KyleRiggen
    Commented Dec 27, 2015 at 23:35
  • is this only for nodes with 0 comments, or if node has 1 comment and 20 min passed and no new comments have been made, still send e-mail?
    – No Sssweat
    Commented Dec 28, 2015 at 0:13
  • Yes if a node has any number of comments and 20 minutes has pass with no additional comments, send email.
    – KyleRiggen
    Commented Dec 28, 2015 at 0:14
  • The approach seems right. Are you using the scheduling system included with Rules? I would suggest you read the documentation (drupal.org/node/1300068) , as it has a few twists. Another thing to keep in mind is that these rules will run when Cron runs. If you are using the default Drupal Cron ("poorman" Cron or " lazy" Cron), it may end up running at irregular intervals, as it only runs if a visitor visits your site. There are ways to schedule Cron to run on more accurate terms - many online articles about this.
    – argiepiano
    Commented Dec 28, 2015 at 1:28

1 Answer 1

2

Overall goal: If a node has not been commented on in an in a given time frame, send an email.

Here is a bare bones solution. On paper this should work.

Basically, we use sticky as the tell tell sign if a new comment has been added (if it's not sticky, no one has commented). Once the e-mail gets sent, we set node to unsticky.

1) Create a rule after saving new comment.

  • Add Action: Under Node, Make Content Sticky >> comment:node

Then it's very similar to my answer to your question Rules Conditions being evaluated after schedule time elapsed?

Create a New Component

1) Add Compotent of Rule.

2) For Data Type: select Node. Name, Label and Machine name use whatever you want.

3) Add condition of Content is of type

  • For Data Selector: put your Node Data Type machine name. Ex: if you gave the node data type a machine name of test you put test
  • Select your content type

4) Download and Install Conditional Rules Module

Then for action, click on Add IF >> DATA COMPARISON >> test:sticky >> False

Then in IF: Data Comparison row click Add Action >> Send Mail

Then in Conditional row (1st row white) you will now see an Else button, click on it.

Then in Else click on Add Action >> Make Content Unsticky >> test

enter image description here

Now Create a new Rule

1) For action use after content is created

2) Leave the condition empty (no need for condition here)

3) for Action add the scheduled component evaluation and select the component you just created.

  • use node as your data selector
6
  • I was thinking the Rule would react on "Cron Maintenance" but I've never worked on this sticky functionality so I'll give it a try!
    – KyleRiggen
    Commented Dec 28, 2015 at 1:18
  • holdon, we need to reset the sticky for when step 4 is sticky (true)...
    – No Sssweat
    Commented Dec 28, 2015 at 1:23
  • I've never used Conditional Rules module, but if you're able to Make Content Unsticky when step 4 is true then this will work.
    – No Sssweat
    Commented Dec 28, 2015 at 1:25
  • The idea behind this is great. I am running into minor issues (or bugs) on how to get the nodes unstickied after an amount of time via the scheduler. I separated out all the Rules to isolate this problem here. So a look inside the relevant Rule is here. Then a look inside the scheduled component here. I am not sure where I am going wrong with being able to schedule a node to become unsticky.
    – KyleRiggen
    Commented Dec 30, 2015 at 3:28
  • @KyleRiggen as I mentioned in my comments above, you need to download the Conditional Rules module. I was gonna let you figure this part out. Anyways, I have installed it to see how it works and updated Step #4.
    – No Sssweat
    Commented Dec 30, 2015 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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