Hi,
I've just been working through the example here:
http://drupal.org/comment/reply/1492498
Which describes how to add site content to a simplenews newsletter using entity reference, views bulk operations, and rules.
The problem I'm having is that this recipe only works for a single list of nodes - I want to have two lists, with recent 'News Stories' shown first, then upcoming 'events'.
I'm thinking of doing it by chaining rules together, with the first rule running when the newsletter is first saved. This would then pass the newsletter nid to a view, which would generate a table of news stories, and invoke another rule to add the stories to the newsletter. This would finish with a page redirect to the events view, which would invoke a final rule to add the events, and redirect back to the newsletter.
The problem I'm having is with how to pass the newsletter nid through the different stages of the process. I was hoping there was an easy way to pass the newsletter nid as an argument to a view, then use this as a table field in the output (which would be the same for all rows). I think this would solve the problem, but I can't figure out how to do it.
I'm using drupal 7 and views 3.
Thanks,
andy baxter
On 16/05/12 18:56, andy baxter wrote:
Hi,
I've just been working through the example here:
http://drupal.org/comment/reply/1492498
Which describes how to add site content to a simplenews newsletter using entity reference, views bulk operations, and rules.
The problem I'm having is that this recipe only works for a single list of nodes - I want to have two lists, with recent 'News Stories' shown first, then upcoming 'events'.
I've solved this by passing the newsletter in the url, and using a custom php value in the rule to get the newsletter id.
- the first rule triggers on saving a new newsletter. - this invokes a view of news stories, which has the first contextual field set as a placeholder (Global: Null). - this calls a rule set component to add the news stories, using views bulk operations. - the first rule in the set gets the newsletter node: - add variable with zero value - change value to arg(2) using a custom php value (you need custom php filters installed). I.e. add an action to change a data value, set the selector to the variable you've created, set the value to the current value of the variable, and add 'return arg(2);' in the value's custom php field. Which argument to get depends on how you named your view. Mine is at /view/newsletter-stories/[nid]. - select newsletter node by id - the second rule in the set adds the news stories as in the example above, then redirects to the 'newsletter events' view. - This works the same as above, but ends up redirecting back to the newsletter node.
You should be able to chain as many rules/views as you like using this method.
If anyone knows of a cleaner way to do it, I'd still be interested (e.g. without using the 'arg' function).
If I get the time, I could write this up somewhere on the drupal site, but I'm not sure where is best?
andy baxter