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   1356 Views

Avatar
lozhowlett

Community Member, 146 Posts

14 September 2011 at 7:18pm

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

Forum Moderator, 5513 Posts

14 September 2011 at 7:55pm

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

Community Member, 146 Posts

14 September 2011 at 9:15pm

Hi willr

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

cheers

Avatar
lozhowlett

Community Member, 146 Posts

15 September 2011 at 12:00am

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

Community Member, 68 Posts

2 August 2013 at 3:58pm

is there a recomended way of doing this for 3.1 please

Avatar
Willr

Forum Moderator, 5513 Posts

2 August 2013 at 6:19pm

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

Avatar
kindlemanwill

Community Member, 68 Posts

7 August 2013 at 5:36pm

Edited: 07/08/2013 5:37pm

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...