[support] simplenews: add multiple lists of nodes to a newsletter

andy baxter andy at earthsong.free-online.co.uk
Thu May 17 06:45:34 UTC 2012


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


More information about the support mailing list