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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

SilverStripe adds slashes to my anchors


Go to End
Reply

10 Posts   4161 Views

Avatar
quamsta

14 January 2009 at 7:46am Community Member, 29 Posts

In one of my templates, I have a small jquery-based tab box. The tab box's navigation relies on anchors to function, so I have something similar to this in the template:

<ul class="tabNavigation">
<li><a class="selected" href="#first">$Tab1Title</a></li>
<li><a class="" href="#second">$Tab2Title</a></li>
<li><a class="" href="#third">$Tab3Title</a></li>
<li><a class="" href="#fourth">$Tab4Title</a></li>
</ul>

unfortunately, whenever SilverStripe parses this template, it adds a slash, '/' to my anchors, which breaks my javascript tabs. Is this a bug or some kind of option that I can turn off in SilverStripe?

When I view the source in my web browser I see this:

<ul class="tabNavigation">
<li><a class="selected" href="/#first">$Tab1Title</a></li>
<li><a class="" href="/#second">$Tab2Title</a></li>
<li><a class="" href="/#third">$Tab3Title</a></li>
<li><a class="" href="/#fourth">$Tab4Title</a></li>
</ul>

Thanks!

Avatar
quamsta

14 January 2009 at 8:58am Community Member, 29 Posts

I found out how to disable the rewriteHashlinks option, but it turns out that the hashes aren't really the issue. there's something else going on with my javascript, I think.

Avatar
derralf

3 July 2009 at 10:08pm Community Member, 24 Posts

i have the same problem...
how and where did you disable the rewriteHashlinks option?

Avatar
Willr

4 July 2009 at 9:46pm Forum Moderator, 5511 Posts

@derralf add this to your config file SSViewer::setOption('rewriteHashlinks', false);

Avatar
derralf

4 July 2009 at 10:20pm Community Member, 24 Posts

@willr thanks!
i already found this snippet yesterday.
additional you have to apply this bugfix to /sapphire/core/SSViewer.php to really really disable hashlink rewriting:
http://open.silverstripe.com/changeset/76529

Avatar
Stijn

9 July 2009 at 12:00am Community Member, 46 Posts

When I on a page like this:

http://www.mysite.com/contact

And in my .ss I write this code:

<li><a href="#tabs">Tab1</a></li>

SilverStripe makes this code:

<li><a href="contact#tabs">Tab1</a></li>

How can I disable, that he place 'contact' in front of # ?

Avatar
Stijn

9 July 2009 at 1:04am (Last edited: 9 July 2009 1:04am), Community Member, 46 Posts

> http://open.silverstripe.com/changeset/76529

This code doenst work ... :-(

Avatar
derralf

9 July 2009 at 5:32am Community Member, 24 Posts

hmm... worked good for me, just did these 2 things:

i put the snipped from willr in my _config.php: SSViewer::setOption('rewriteHashlinks', false);

and in my sapphire/trunk/core/SSViewer.php i put the fix from http://open.silverstripe.com/changeset/76529 by replacing the "red part" by the "green part".

(with Silverstripe 2.3.2 stable)

Go to Top