Some easy steps to embed a view with latest articles in your newsletter.

  1. Create some article nodes
  2. Install views and create a view called latest_articles
  3. Activate the core module PHP filter
  4. Goto admin/newsletters/templates/mail and edit the default template (or create a new one)
  5. 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();
    ?>
    
  6. Done: goto admin/newsletters/create-send/new and send your newsletter
CommentFileSizeAuthor
#18 diff.txt9.28 KBerickrholanda
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ParisLiakos’s picture

Status: Active » Fixed

Marking it as fixed to clear up the queue.
But very helpful for people new to Drupal

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

joecanti’s picture

Version: » 7.x-1.0-beta5

Great tutorial - thanks for posting...

bjlewis2’s picture

When I followed these instructions, my newsletter sent with this:

set_display('block_1'); print $view->preview(); ?>

so it looks like the ">" from $view->set_display is ending the <?php

Any thoughts?

bjlewis2’s picture

The exact code I put in is:

<?php
$view = views_get_view('modules_unraveled_podcast');
$view->set_display('block_1');
print $view->preview();
?>
Tran’s picture

Same as above

jmvidal’s picture

This 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?

Anticosti’s picture

Thanks 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,

doliveros’s picture

This doesn't seems to work with more recents versions of this module, did they disabled php filter format support?

doliveros’s picture

Issue summary: View changes

wording

astutonet’s picture

Issue summary: View changes
Status: Closed (fixed) » Active
astutonet’s picture

I'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?

derjochenmeyer’s picture

I did not test this, but someone recommended
https://drupal.org/project/pathologic

astutonet’s picture

I'm already using Pathologic

astutonet’s picture

Through 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 :-)

cassioDourado’s picture

hi, 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?

geoo’s picture

To remove the "Edit view" link from mail body, in your view's editor look in 'Others' section and switch 'Hide contextual links' to Yes.

arruk’s picture

Same 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?

erickrholanda’s picture

FileSize
9.28 KB

Hi, 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.

erickrholanda’s picture

Status: Active » Needs review