Last modified: 2004-12-07 01:27:35 UTC
Please allow links with dotdot syntax to reference up the subpage hierarchy. This is very useful for deep subpage hierarchies (which are perhaps only useful in intranets). Here are simple examples (assume we are editing page A/B/C/D): [../E] --> references A/B/C/E [../../../W/X] --> references A/W/X Here is a mediocre implementation for version 1.3.8 (if this gets mangled, email me at john_b_andrews@yahoo.com for a copy): Parser.php diff: 1197,1213d1196 < # JBA inserted code here < # The two inserted code snippets allow .. syntax like this: < # [[../Foo]] or [[../../Bar]] < # Limitations: < # - ..s can only occur at beginning < # - cannot go past your top subpage < # - cannot just do .. or ../..; must have / and something not-.. < $jba_cd_dot_dot = 0; # count # of leading ../ occurrences < $jba_orig_m1 = $m[1]; < if(substr($m[1],0,3) == '../') { < while(substr($m[1],0,3) == '../') { < $jba_cd_dot_dot = $jba_cd_dot_dot + 1; < $m[1] = substr($m[1],3); < } < $m[1] = '/' . $m[1]; < } < # JBA end of code insertion 1224,1241c1207 < # JBA inserted code here < $jba_prefix = $this->mTitle->getPrefixedText(); # Prefix to be prepended < < # Remove $jba_cd_dot_dot number of /words on the end of the prefix < if ($jba_cd_dot_dot) { < $jba_substrings = explode('/', $jba_prefix); < $jba_substrings = array_slice($jba_substrings, 0, -$jba_cd_dot_dot); < # Implode seems to malfunction if $jba_substrings is one element. < if (count($jba_substrings) == 1) { < $jba_prefix = $jba_substrings[0]; < } < else { < $jba_prefix = implode('/', $jba_substrings); < } < } < < # Prepend the prefix to the suffix to form the link. < $link = $jba_prefix . '/' . trim($noslash); --- > $link = $this->mTitle->getPrefixedText(). '/' . trim($noslash); 1243c1209 < $text= $jba_orig_m1; --- > $text= $m[1]; 1245,1246d1210 < # JBA end of code insertion
Created attachment 141 [details] Example implementation of requested feature.
I've added this feature to the HEAD (1.5) branch of CVS. Assuming we're at page A/B/C/D: [[../../]] links to A/B [[../../E]] links to A/B/E If no link title is given, then the full page path will be used, except if the link is followed by an extra slash, eg [[../F/]] renders simply as F, while [[../F]] will render as A/B/C/F. Of course you can use the pipe title format as per any other link. Note you can not go above the top level page with this, for this example [[../../../../G]] will not be reated as a valid link.