Jump to:

21278 Posts in 5728 Topics by 2599 members

General Questions

SilverStripe Forums » General Questions » CMS auto inserting page URL before # anchor

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

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 493 Views
  • lozhowlett
    Avatar
    Community Member
    105 Posts

    CMS auto inserting page URL before # anchor Link to this post

    Hi everyone

    I have an issue, SS is auto putting URL into my A tags...

    <ul class="tabs"><li><a href="northampton-seo-company#tab1">Real SEO Company</a></li>
    <li><a href="northampton-seo-company#tab2">The RIGHT choice</a></li>
    <li><a href="northampton-seo-company#tab3">Our Ethics</a></li>
    <li><a href="northampton-seo-company#tab4">Here to help!</a></li>
    </ul>

    in the CMS it is

    <ul class="tabs"><li><a href="#tab1">Real SEO Company</a></li>
    <li><a href="#tab2">The RIGHT choice</a></li>
    <li><a href="#tab3">Our Ethics</a></li>
    <li><a href="#tab4">Here to help!</a></li>
    </ul>

    How do I turn it off? As my script wont work with the first example...

    Any help would be great! thanks,

  • Willr
    Avatar
    Forum Moderator
    5163 Posts

    Re: CMS auto inserting page URL before # anchor Link to this post

    SS does that automatically to fix any issues with having the base url defined. You can disable the behavior using SSViewer:: dontRewriteHashlinks();

    http://api.silverstripe.org/2.4/sapphire/view/SSViewer.html#methoddontRewriteHashlinks

  • lozhowlett
    Avatar
    Community Member
    105 Posts

    Re: CMS auto inserting page URL before # anchor Link to this post

    Hi willr

    thanks for that. Does this go into mysite/_config.php?

    cheers

  • lozhowlett
    Avatar
    Community Member
    105 Posts

    Re: CMS auto inserting page URL before # anchor Link to this post

    Got it working.

    You edit the code in mysite/code/page.php.

    Simply add the line to:

    public function init() {
          parent::init();

    ...
    SSViewer::dontRewriteHashlinks();

    thanks

    493 Views
Page: 1
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.