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'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.

All other Modules /

Discuss all other Modules here.

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

Newsletter Modul generate Links like this: [sitetree_link id=18]


Go to End


7 Posts   2920 Views

Avatar
Christian Hilles

Community Member, 6 Posts

16 September 2010 at 5:36am

Hi,

since Silverstripe 2.4 i have an problem with internal Links in a Newsletter.

I think, that's a effect of the new nested URL's.. I hope you know the real reason and can help me! :)

The Newsletter Modul generate links like this: <a href"=[sitetree_link id=18]">

If i click: Silverstripe call the 404 Page.

(Sorry for my bad english!!!)

Christian :)

Avatar
Mad_Clog

Community Member, 78 Posts

24 September 2010 at 12:16am

I was having the same problem.
This is caused the Body/Content is passed as plain text rather then an instance of HTMLText.

Fix:
NewsletterAdmin.php ~ line 572

        $e = new Newsletter_Email($nlType);
        $body = new HTMLText();
        $body->setValue($newsletter->Content);
        $e->Body = $body;
//        $e->Body = $body = $newsletter->Content;
        $e->Subject = $subject = $newsletter->Subject;

Fix 2:
NewsletterAdmin ~ line 160

        // Set template specific variables before passing it to the template
        $obj->Body = new HTMLText();
        $obj->Body->setValue($obj->Content);

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

Avatar
Christian Hilles

Community Member, 6 Posts

28 September 2010 at 12:47am

Thank's a lot Mad_Clog :)

It work's fine!!!

Avatar
Mr007

Community Member, 1 Post

28 September 2010 at 6:38am

I hope you know the real reason

__________________
global trade
Cartoon Character Jackets

Avatar
Christian Hilles

Community Member, 6 Posts

28 September 2010 at 6:59am

The real reason? Now i'm curious about it.

My problem is fixed with Mad_Clog's code. But i would be deeply grateful to hear more about the real reason. :)

Avatar
Martijn

Community Member, 271 Posts

28 September 2010 at 7:20am

Mr007 : spamrabbit...

Avatar
figj

Community Member, 12 Posts

9 February 2011 at 10:46pm

This happens because the shortcode parser (for links) isn't invoked if you render a template yourself.

So another solution is to simply call it yourself:

   $data = $this->renderWith( $template ); 
    return ShortcodeParser::get_active()->parse($data); 

See also: Re: Page Links error in FirstParagraph