Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Newsletter URL

Go to End

10 Posts   4192 Views


Community Member, 30 Posts

7 October 2009 at 9:56am

Is there a usable URL for the newsletter that can be included IN the newsletter somewhere? That way if there are usability issues with HTML emails a link can still be provided to view the content in a browser?


Community Member, 24 Posts

7 October 2009 at 4:00pm

Edited: 07/04/2010 4:30pm

I found a workaround for this but it requires editing one of the Newsletter files (there is probably a better way, but this was the one I used because it was the fastest for me...)

Please look further down the page for the new updated hack


Community Member, 30 Posts

8 October 2009 at 11:27am

Edited: 08/10/2009 11:48am

ok so what did I do wrong, I am a bit new at some of this stuff

Fatal error: Call to undefined method stdClass::hasMethod() in C:\xampp\htdocs\ss\sapphire\core\ViewableData.php on line 1064

If I edit out the Home on newsletter.php, assuming home is just the home directory I simply get a page cannot be displayed error with a url of



Community Member, 211 Posts

12 January 2010 at 11:09pm


I tried this code and it seems to work the only thing that is not working is that it is changing the url for pitctures from
(this the right URL for the pictures and is theone you can see in the html code in the editor


Wich seems not to work properly because it acts like the image is there (if your right click with your mouse on a pc you get the menu saying save image) but it is not

I can feel I'm very close to finding a solution please help

Thank You


Community Member, 8 Posts

28 March 2010 at 9:07pm

Was there a solution to this? I am experiencing the same error message...


Community Member, 8 Posts

6 April 2010 at 8:05pm

Has anyone come up with a solution for this... I am still have the following error:
Fatal error: Call to undefined method stdClass::hasMethod() in /var/www/vhosts/ on line 1064

The script above seems to continue to refer to the following URL no matter what edition of newsletter sent, if I manually change the last number to 30, it shows #30 newsletter.


Community Member, 24 Posts

7 April 2010 at 4:28pm

Edited: 08/04/2010 2:17am

Sorry it took so long for me to reply, I have finally fixed the coding for this (this is for newsletter version 0.4.0, I hope it works for other versions as well). Before you perform the following changes, ALWAYS BACKUP YOUR FILES (in this case, especially Newsletter.php, NewsletterAdmin.php, NewsletterEmailProcess.php and Page.php)

I am still not sure how to decorate the newsletter_email class with new methods (I hope somebody can update my code so it is a decorator, rather than a replacer, because replacing code in modules is a no no). Anyways, replace the Newsletter_Email class (at the end of Newsletter.php) with the following:

 * Email object for sending newsletters.
 * @package newsletter
class Newsletter_Email extends Email {

	protected $nlType;
	protected $newsletter;

	function __construct($nlType, $newsletter = null) {
		$this->nlType = $nlType;
		$this->newsletter = $newsletter;

	function setTemplate( $template ) {
		$this->ss_template = $template;

	function UnsubscribeLink(){
		$emailAddr = $this->To();
		$nlTypeID = $this->nlType->ID;
		return Director::absoluteBaseURL() . "unsubscribe/index/$emailAddr/$nlTypeID";
	function ViewLink(){
		$newsletter_id = $this->newsletter->ID;
		$page_link = DataObject::get_one('SubscribePage')->Link();
			$page_link = DataObject::get_one('SubscriptionPage')->Link();
			$page_link = DataObject::get_one('SubscribeForm')->Link();
			$page_link = DataObject::get_one('Page')->Link();
		return $page_link . 'ViewNewsletter/' . $newsletter_id;

Now you can use $ViewLink in your Newsletter template to get the view online version url for your newsletter.

Now go into NewsletterAdmin.php and replace this line:

$e = new Newsletter_Email($nlType);

With this line:

$e = new Newsletter_Email($nlType, $newsletter);

In NewsletterEmailProcess.php replace the following line:

$e = new Newsletter_Email($this->nlType);

With this:

$e = new Newsletter_Email($this->nlType, $this->newsletter);

Now add the following code to your Page.php in the controller class (Page_Controller), best place is at the end (what I did, I extended the Subscription Page with a new page, Subscribe Page, and added this code in the controller for that new page):

function ViewNewsletter() {
		$params = Director::urlParams(); 
		$newsletterID = (int)$params['ID'];
		$obj = DataObject::get_by_id('Newsletter', $newsletterID);
		$templateName = ($obj && ($obj->Parent()->Template)) ? $obj->Parent()->Template : 'GenericEmail';

		// Block stylesheets and JS that are not required (email templates should have inline CSS/JS)

		// Set template specific variables before passing it to the template
		$page = new Page();
		$page->Title = $obj->Subject;
		$obj->Content = str_replace('src="assets','src="'.Director::baseURL().'assets',$obj->Content);
		$obj->Content = str_replace('class="right"','align="right"',$obj->Content);
		$page->Body = str_replace('class="left"','align="left"',$obj->Content);
		$page->UnsubscribeLink = Director::absoluteBaseURL() . "unsubscribe/index/";
		$page->ViewLink = $this->Link . "ViewNewsletter/" . $newsletterID;

		return $this->customise($page)->renderWith($templateName);


Community Member, 8 Posts

7 April 2010 at 9:44pm

Thanks very much... I have tried your instructions and after a flush all seems okay... However now when clicking send in the newsletter it comes up in the status bar "Error SendNewsletter" then changes to "saved".

To confirm you are suggesting creating a new php page being "SubscribePage" instead of editing "Page.php"? Obviously the previous entered info into the "page.php" page also needs to be removed.

- any ideas?


Go to Top