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.

General Questions /

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

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

SilverStripe adds slashes to my anchors


Go to End


10 Posts   6031 Views

Avatar
quamsta

Community Member, 29 Posts

14 January 2009 at 7:46am

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

Community Member, 29 Posts

14 January 2009 at 8:58am

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

Community Member, 28 Posts

3 July 2009 at 10:08pm

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

Avatar
Willr

Forum Moderator, 5523 Posts

4 July 2009 at 9:46pm

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

Avatar
derralf

Community Member, 28 Posts

4 July 2009 at 10:20pm

@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

Community Member, 46 Posts

9 July 2009 at 12:00am

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

Community Member, 46 Posts

9 July 2009 at 1:04am

Edited: 09/07/2009 1:04am

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

This code doenst work ... :-(

Avatar
derralf

Community Member, 28 Posts

9 July 2009 at 5:32am

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