I have been searching for an answer to this every where I can think of, and can't find a specific, direct answer, so I am assuming I may be doing something wrong. Here is what I would like to do- Render a View in the body of email that is sent from Rules acting on a list of users created by a VBO. It seems like this would be a normal thing for people to want to do, so again I must be missing something obvious, and if so I apologize in advance, but if you could be so kind as to explain explicitly what I need to do in a Rules component that would be great!
With Drupal 7.14,
- Mime Mail 7.x-1.0-alpha1+9-dev
- Entity API 7.x-1.0-rc3
- Token 7.x-1.1
- Rules 7.x-2.1
- CKEditor 7.x-1.9
I have a VBO that acts on Users. I send that list to a Rules component as a parameter. I use the action send HTML email (or regular email- I've tried both).
I thought maybe I needed the Rules Bonus Pack, but the documentation on this says don't run in a production environment.
I have tried this PHP code ( echo views_embed_view(‘view_name’, $display_id = ‘view_display_name’) ;
) from the Rule, as well as placing it in a Body field of a Node and then fetching that all to no avail.
I am hoping there is some glaringly obvious thing I need to do to make this work! Please, please advise!
Comments
Comment #1
usmith CreditAttribution: usmith commentedI am going to answer my own question. I found out today that there was a patch required for embed view to work. You need to look at this note- http://drupal.org/node/1471770- and apply the patch posted on May 25, 2012. After that I was able to use the following PHP code in an HTML email and a field on a node using the PHP format.
echo views_embed_view(‘machine_name_of view’, $display_id = ‘machine_name_of_view_display_name’) ;
Comment #2
neRok CreditAttribution: neRok commentedI have the same scenario and cannot find a solution.
I have a view which has a list of recently created nodes.
I have a rule with schedule that sends an email ('newsletter') to users periodically.
I want the content/output of the view to be the emails body.
This should be simple, but I cant work it out. I would rather not use PHP input filter as per above, but I couldnt find out how to enable that either.
Comment #3
thomasmurphy CreditAttribution: thomasmurphy commentedI tried the PHP in #1 but I didn't get it working, but
print views_embed_view('test', 'embed_1');
worked :)
Comment #4
hschott CreditAttribution: hschott commentedI got it to work using #3, but had to fill in an email address in the from value, even though there is a site wide email address set.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedI'm in the situation of wanting to embed the output of a view in the body of an Workflow email and have tried #3 with #4, but am only getting the output from the Empty Results Behavior defined in the view.
The view displays results both in the view preview and when using #3 on a test node, but does not return the expected results when run by Workflow in the body of an email.
I've set the access restrictions on the view to None, but could there be a problem with Workflow accessing the underlying nodes?
Can anyone offer any suggestions on how I can get this working?
Any help would be greatly appreciated!
Thanks.
Comment #6
TR CreditAttribution: TR commentedA solution was given in #3. #5 seems to be a different problem.
Comment #7
TR CreditAttribution: TR commented