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

Anchor links in newsletters


Go to End


4 Posts   2249 Views

Avatar
Phill

Community Member, 81 Posts

13 October 2010 at 5:46am

Hi

Im creating a newsletter through the newsletter module which contains links to anchor points in the email.

Because SS converts the anchor links into absolute urls (#my-anchor becomes www.mysite.com/#my-anchor) the anchor links no longer work.

I also had to add a <base tag to make images entered through the newsletter module visible in the email preview which may be causing part of the problem.

I've worked out a possible hack of adding an id to the table containing the links to the anchors, which would then make it possible to use simplexml to parse the content and convert the absolute urls back to relative urls. Does anyone have a better idea of how to achieve this result as i don't really want to edit the core newsletter module files.

Thanks
Phil

Avatar
_Vince

Community Member, 165 Posts

20 December 2010 at 12:31pm

*bump*

Any ideas..?

Avatar
mi3ll

Community Member, 24 Posts

20 December 2010 at 4:18pm

I'm not sure if this will work, but try putting this in your mysite/_config.php file

SSViewer::setOption('rewriteHashlinks', false);

This will stop silverstripe from rewriting ALL hash links in your site.

Avatar
_Vince

Community Member, 165 Posts

21 December 2010 at 9:30am

No... that's not QUITE it. The links now point to

http://www.mysite.com#whatever-the-anchor-was-called

as opposed to

http://www.mysite.com/newsletter/sendNewsletter#whatever-the-anchor-was-called

but it's still not pointing to the newsletter itself.

Thanks a heap for the suggestion though! :)