Dear Drupal Community,

I am hoping that there is a simple way to add a "View Email in Browser" in any newsletter sent via Simplenews. I'd like folks to be able to view newsletters in their browser and also forward the link to others and post on other sites.

Asking too much or is it easy-peasy? Can someone let me know if I need to repost somewhere else for support?

Thanks,
BN

Comments

Ujin’s picture

I couldn't find this out of box. But as alternative solution you can create views page with path like newsletter/% argument nid, from url, and output it content. After this in your theme create tpl file like page--newsletter.tpl.php (for drupal 7 ) or page-newsletter.tpl.php (drupal 6) and put there just html you need. And in your email add link like newsletter/10.

May be somebody know better solution?

Marko B’s picture

Nothing is easy peasy with newsletters. As Ujin suggested, build a view or if your NL is simple, just point your users to a node you created when you did your NL issue as there is always one when you create new NL.

Marko B’s picture

Issue summary: View changes

Verifying post

maki3000’s picture

Issue summary: View changes

disclaimer: there are many ways to setup and theme a simplenews newsletter. here, i'm talking about having a simplenews-newsletter-body.tpl.php file in my themes templates folder..

i got the same problem here. i want to have a "View in browser" inside my simplenews-newsletter-body.tpl.php. the only thing i managed to have is:

<a href="<?php echo $base_url . '/node/' . $build['#node']->nid; ?>" target="_blank">View in browser</a>

(i'm in drupal7 btw.)

i have a global $base_url; in top of the file. and then link to

<?php echo $base_url . '/node/' . $build['#node']->nid; ?>

this works. so a user can open the NL in the browser. but i find it not really nice to have e.g. ".../node/76" in the url. i wanted to have the URL-Alias of the NL in the URL, but didn't manage to find out, how to retrieve it out of a token or the $build['#node']

in drupal6 it was an easy thing. it worked with a token just like that:

<a href="[simplenews-newsletter-url]">View in browser</a>
maki3000’s picture

i got it: just [node:url] did it!

Anonymous’s picture

maki3000, you have salvaged my newsletter!
I have been struggling for days to get a Read Online link on the Simplenews Newsletter.
I have looked everywhere and couldn't find anything.

Here is the code that worked for me in the end:

Read the full post

sander-martijn’s picture

Thank you maki3000! Took me hours of reading through and trying out other suggestions that didn't work, and turns out to be such a simple solution!

I love drupal. I hate the lack of good documentation.

robcarr’s picture

For those confused... insert the line

<h2><a href="[node:url]" title="Read this Newsletter online"><?php print $title; ?></a></h2>

Into simplenews-newsletter-footer.tpl.php (which you will have copied into your own theme).

marco.staub’s picture

For those who wanted to do that in Drupal 9:

Copy modules/contrib/simplenews/templates/simplenews-newsletter-body.html.twig to your theme and edit it, e.g.:

[...]
<div class="viewl-browser-link"><a href="https://<yourside>/node/{{node.id}}">Read this Newsletter online</a></div>
<h2>{{ title }}</h2>
[...]

(Maybe there is a better Attribute than node.id, e.g. the full url, but this will do it)