Jump to:

23453 Posts in 18904 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » SilverStripe adds slashes to my anchors

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

Page: 1 2
Go to End
Author Topic: 4110 Views
  • quamsta
    Avatar
    Community Member
    29 Posts

    SilverStripe adds slashes to my anchors Link to this post

    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!

  • quamsta
    Avatar
    Community Member
    29 Posts

    Re: SilverStripe adds slashes to my anchors Link to this post

    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.

  • derralf
    Avatar
    Community Member
    24 Posts

    Re: SilverStripe adds slashes to my anchors Link to this post

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

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: SilverStripe adds slashes to my anchors Link to this post

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

  • derralf
    Avatar
    Community Member
    24 Posts

    Re: SilverStripe adds slashes to my anchors Link to this post

    @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

  • Stijn
    Avatar
    Community Member
    46 Posts

    Re: SilverStripe adds slashes to my anchors Link to this post

    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 # ?

  • Stijn
    Avatar
    Community Member
    46 Posts

    Re: SilverStripe adds slashes to my anchors Link to this post

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

    This code doenst work ...

  • derralf
    Avatar
    Community Member
    24 Posts

    Re: SilverStripe adds slashes to my anchors Link to this post

    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)

    4110 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.