Closed (fixed)
Project:
Insert View
Version:
7.x-2.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
14 Oct 2015 at 06:53 UTC
Updated:
27 Jul 2020 at 02:37 UTC
Jump to comment: Most recent
Comments
Comment #2
michaeldknox commentedDid you ever find an answer? I'm trying to do the same thing.
Comment #3
thomasmurphy commentedI looked into this too, but it didn't work. I've managed to embed the view using one line of PHP though, based on
https://api.drupal.org/api/views/views.module/function/views_embed_view/...
e.g.
print views_embed_view('your_view', 'you_display');Comment #4
hschott commentedI'm trying to do the same thing. NO luck. thomasmurphy, where did you put this line of code? Are you doing this through Rules? I tried putting it in the rules value for the body, but it just prints it out the line exactly in the email, not getting the view. Is it possible to put php in the rules/ action/ sendmail/ body?
Comment #5
thomasmurphy commentedHi hschott, yes it's in a rule.
Are you putting the php inside
<?php ?>tags? Without them Drupal will treat the PHP as text rather than interpreting it. This can work in the message body, or I'm defining a text variable as an action in the view and including the variable in message body, which was easier to debug in my case.Also, you need an embed type view display, which you need to enable via the view settings (/admin/structure/views/settings)
Ideally we could do with a module which allows views embedding in rules via tokens, to avoid putting PHP in the database, but I'm not aware of one that works and don't have the time to put into making one, ho hum.
Comment #6
hschott commentedThanks for responding thomasmurphy. I do have the php tags. I did finally get it to work, but not sure how exactly. All I did was enter an email address in the from value, even though it says you can leave it blank and it will use the sitewide email, which I do have set.
Comment #7
renatog commentedHi guys.
I'm checking it and #5 really make sense. It helps me here.
Comment #8
renatog commentedThank you for your help @thomasmurphy
Comment #10
TimelessDomain commentedIs this still the only way to embed an insert view into a rules email? Can you please provide the full coding to make this work?
Is it
<?php print views_embed_view('your_view', 'your_display');?>?Comment #11
TimelessDomain commentedThis should be working with the html mail module but it doesn't. See https://www.drupal.org/project/htmlmail/issues/3161081
Comment #12
TimelessDomain commented<?php print views_embed_view('your_view', 'your_display');?>does work! Just remember to turn on the php filter module and enable it in text formatsI'm using the HTML Mail module to enable Post-filtering "You may choose a text format to be used for filtering email messages after theming. This allows you to use any combination of over 200 filter modules to make final changes to your message before sending."