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

CMS auto inserting page URL before # anchor


Go to End


7 Posts   4020 Views

Avatar
lozhowlett

Community Member, 151 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, 5523 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, 151 Posts

14 September 2011 at 9:15pm

Hi willr

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

cheers

Avatar
lozhowlett

Community Member, 151 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
kindleman.com.au

Community Member, 70 Posts

2 August 2013 at 3:58pm

is there a recomended way of doing this for 3.1 please

Avatar
Willr

Forum Moderator, 5523 Posts

2 August 2013 at 6:19pm

Avatar
kindleman.com.au

Community Member, 70 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...