Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Some easy steps to embed a view with latest articles in your newsletter.
- Create some article nodes
- Install views and create a view called latest_articles
- Activate the core module PHP filter
- Goto admin/newsletters/templates/mail and edit the default template (or create a new one)
- Choose "PHP code" as Text format and paste the following code in your template:
<?php $view = views_get_view('latest_articles'); $view->set_display('default'); print $view->preview(); ?>
- Done: goto admin/newsletters/create-send/new and send your newsletter
Comment | File | Size | Author |
---|---|---|---|
#18 | diff.txt | 9.28 KB | erickrholanda |
Comments
Comment #1
ParisLiakos CreditAttribution: ParisLiakos commentedMarking it as fixed to clear up the queue.
But very helpful for people new to Drupal
Comment #3
joecanti CreditAttribution: joecanti commentedGreat tutorial - thanks for posting...
Comment #4
bjlewis2 CreditAttribution: bjlewis2 commentedWhen I followed these instructions, my newsletter sent with this:
so it looks like the ">" from
$view->set_display
is ending the<?php
Any thoughts?
Comment #5
bjlewis2 CreditAttribution: bjlewis2 commentedThe exact code I put in is:
Comment #6
Tran CreditAttribution: Tran commentedSame as above
Comment #7
jmvidal CreditAttribution: jmvidal commentedThis works!
But, my content has relative URLS to my site which, of course, do not work when the user clicks on them in his email (they show up as http://path/to/content without the hostname).
Does anyone know how I can filter the content to change urls to absolute?
Comment #8
Anticosti CreditAttribution: Anticosti commentedThanks to derjochenmeyer for this great tutorial.
This is working great.
The only problem I have is that all the newsletters created,
all have the same exact latest articles, when the user clicks (in the email he received)
on the link "Click here to read this Newsletter on our Site".
How could I now make these Newsletters' content "freeze" in time?
Any help will be welcome.
Kind Regards,
Comment #9
doliveros CreditAttribution: doliveros commentedThis doesn't seems to work with more recents versions of this module, did they disabled php filter format support?
Comment #9.0
doliveros CreditAttribution: doliveros commentedwording
Comment #10
astutonetComment #11
astutonetI'm testing this module and got results very good with this tutorial, but there is a problem:
I also have the same issues as #7 and the links of the my content has relative URLS to my site.
Probably no answer because the question was closed.
Any idea?
Comment #12
derjochenmeyer CreditAttribution: derjochenmeyer commentedI did not test this, but someone recommended
https://drupal.org/project/pathologic
Comment #13
astutonetI'm already using Pathologic
Comment #14
astutonetThrough the settings of views module, I managed to create Newsletters using the absolute path in the ULRs with the above php code.
What I did:
I created a View using fields. I inserted the fields I wanted, including the "Title" field. So, in the settings of this field, I selected "Link this field to the original content", "Rewrite the output of this field", "Display this field as a link" and finally "Use absolute path".
For now, this is the solution, is the tip :-)
Comment #15
cassioDourado CreditAttribution: cassioDourado commentedhi, i managed to insert the result of the view template in the newsletter, but when I create a newsletter and send send the test email it is coming up with a link "Edit view". How can I remove this link newsletter?
Comment #16
geoo CreditAttribution: geoo commentedTo remove the "Edit view" link from mail body, in your view's editor look in 'Others' section and switch 'Hide contextual links' to Yes.
Comment #17
arruk CreditAttribution: arruk commentedSame question as #9
Also all the Taxonomy terms listed on the page could use some documentation. Is this going to automatically bundle the content from selected terms? If so, where are the setting to format it?
Comment #18
erickrholanda CreditAttribution: erickrholanda commentedHi, I have same problem. I have to send weekly newsletter with few nodes, content type Releases. The nodes are associated with another nodes by node reference. So, i don't have taxonomy associated to the nodes and the module newsletter don't get nodes to send. I build a function to the template use a view to get result's and i config the view with the filters and number of the results.
See the diff.txt and help me to commit this for the module project.
Comment #19
erickrholanda CreditAttribution: erickrholanda commented