r4 - 29 Jul 2004 - 00:48:21 - SamHaslerYou are here: TWiki >  Codev Web > RelativeAnchorLinks
Tags:
, create new tag
I would like to request that the Anchor links are relative to the page. The main reason is so that my users can save the pages locally and then use the Anchor links without the browser constantly trying to get online.

I solved this simply by changing the line 1768 in TWiki.pm from

       $text .= "<a href=\"$scriptUrlPath/view$scriptSuffix/"
             .  "$theWeb/$theTopic\#$anchor\">$theLinkText<\/a>";
to
       $text .= "<a href=\"\#$anchor\">$theLinkText<\/a>";

Then in the template file I got rid of the base href, and everything seems to work fine.

A desireable side effect is that now themes work within pages, before, everytime I click on an anchor link it would switch back to the default skin, which was very annoying.

Can anyone think of any undesireable side affects to this change, and would it be a good thing to be integrated into the core?

-- AaronPee - 20 Feb 2002

This seems like a good idea, and I can't think of any side effects. In fact, TWiki's use of a BASE HREF element and absolute URLs has caused some problems in the past, see WhyBaseTag and RelativeURLs.

I've just written some code to get rid of the BASE tag in locally saved files (see ReadOnlyOfflineWiki) - if the tag is still there, IE5/IE6 don't handle links to other saved files properly.

-- RichardDonkin - 20 Feb 2002

I just made changes to WebChangesForAllWebs to get round this problem. Not that using TOC links on any page artived at via a Web.Topic url currently requires reloading because all the TOC links are absolute in Web/Topic format.

I understand the reason for supporting the $web.$topic syntax, but would it have been better implemented as an apache redirect instead of in the code?

-- SamHasler - 29 Jul 2004

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r4 < r3 < r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback SourceForge.net Logo