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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo


Go to End

2 Posts   1881 Views


Forum Moderator, 224 Posts

5 June 2007 at 11:14am

Hi Folk

rewriteHashlinks (part of the sapphire/core/SSviewer.php file), is really useful (it adds the current URL any links starting with # (internal links e.g. <a href="#top">go to the top</a>) , but unfortunately, it does not apply to the content (the data that is entered in the CMS by the admin) of the page itself. How would you recommend I go about implementing it in the content itself?

Any hints much appreciated.



Forum Moderator, 224 Posts

5 June 2007 at 11:46am

Edited: 05/06/2007 11:47am


This is what I have written in JS to fix it....
var currentUrl = location.href;
var As = document.links;
for(i = 0; i < As.length; i++) {
var A = As;
if(A.href) {
var afterHash = A.href.split("#")[1]
if(afterHash) {
if(afterHash.length > 0) {
A.href = currentUrl + "#" + afterHash;