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?
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
- Page 11(current)
- 2
- Next 10 entries
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
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
/ss/ViewNewsletter/1
Hi
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
http://www.mysite.com/assets/newsletter-01/newsletter3.jpg
(this the right URL for the pictures and is theone you can see in the html code in the editor
to
http://www.mysite.com/admin/newsletter/preview/assets/newsletter-01/newsletter3.jpg
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
Was there a solution to this? I am experiencing the same error message...
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/mysite.com/httpdocs/sapphire/core/ViewableData.php on line 1064
The script above seems to continue to refer to the following URL http://www.mysite.com/home/ViewNewsletter/3 no matter what edition of newsletter sent, if I manually change the last number to 30, it shows #30 newsletter.
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;
parent::__construct();
}
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();
if(!$page_link)
$page_link = DataObject::get_one('SubscriptionPage')->Link();
if(!$page_link)
$page_link = DataObject::get_one('SubscribeForm')->Link();
if(!$page_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)
Requirements::clear();
// 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);
}
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?
Cheers...
- Page 11(current)
- 2
- Next 10 entries