0

I want to make a component that receives a user as parameter, and will then do something with some of that user’s content.

That something is: delete nodes of contenttype FICHE that have a due date in the past and copy the content of that node to a variable_mailbody. Send the variable_mailbody when all records of that user are processed. (After testing the component, it will be called in a viewloop of all active users, so it will be executed for all members, one after another, periodically.)

I know how to make a view that selects all nodes with a due date in the past. This will give me all the nodes to delete, but I want only those for this respective user, because I do not want to send a mail for each deleted item.

So how to configure contextual filter to limit the result to only the nodes of the user for which the component is being executed? Or should I tackle this in a different way?

1

Make 2 rules-views on NODES, on both views add relationship to author, on first view only add one field UID using relationship and aggregation, filter your nodes as needed, this will display only one user for several nodes that matched your ‘delete criteria’. On second view add only one field NID (with no aggregation) and same filter criteria as first view, in this view add a contextual filter on UID. On both views set row variable settings in middle column, make all fields and parameters as Data Type = Integer, do not send them as objects, it does not work well. Now in your component or rule, first add your first view-loop (UIDs), fetch user by id using your UID variable, inside that loop, add your second view (NIDs), set contextual filter as your variable UID, loop all those nodes, fetch each node by id usig your NID variable, and do your stuff, outside second view loop, but inside first view loop send your email. On second view loop you can add node-content to a variable previously added to hold all node-data for that user and included in your email body.

  • Great! it works. It was the "Data Type = integer" that was the most essential part of the answer. – sigridt May 8 '18 at 18:51
  • you are welcome, about "Data Type = integer" i struggled a lot, then i found that way it works, i love rules-views, you can do anything, take a look at this answer, that's the way i do a lot of stuff. drupal.stackexchange.com/questions/135647/…, regards – pinueve May 8 '18 at 19:19
  • one more thing, talking same matters, in orther to send body field, taxonomy term or so to views-rules, in row variable settings do choose to 'use rendered output' format, but i prefer to send ID's as an integer and fetch object inside rules, may be a bad way to do it because you load more data than needed, but this way works every time. – pinueve May 8 '18 at 20:41

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.