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

CMS auto inserting page URL before # anchor


Reply

7 Posts   1286 Views

Avatar
lozhowlett

14 September 2011 at 7:18pm Community Member, 146 Posts

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,

Avatar
Willr

14 September 2011 at 7:55pm Forum Moderator, 5511 Posts

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

Avatar
lozhowlett

14 September 2011 at 9:15pm Community Member, 146 Posts

Hi willr

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

cheers

Avatar
lozhowlett

15 September 2011 at 12:00am Community Member, 146 Posts

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

Avatar
kindlemanwill

2 August 2013 at 3:58pm Community Member, 68 Posts

is there a recomended way of doing this for 3.1 please

Avatar
Willr

2 August 2013 at 6:19pm Forum Moderator, 5511 Posts

@asecondwill - http://doc.silverstripe.org/framework/en/3.1/reference/templates#fragment-link-rewriting

Avatar
kindlemanwill

7 August 2013 at 5:36pm (Last edited: 7 August 2013 5:37pm), Community Member, 68 Posts

thanks. From that page:
"There are cases where this can be unhelpful. HTML fragments created from Ajax responses are the most common. In these situations, you can disable fragment link rewriting by setting the SSViewer.rewrite_hash_links configuration value to false."

which you do like this:

// /mysite/_config/confg.yml
SSViewer:
--rewrite_hash_links: false

(replace -- with two spaces, i couldn't make the code block play nice)

in case anyone ends up here after me...