djiles
I'm trying to create some internal links between pages but instead of going to the top of the "linked-to" page I want to go to a specific spot on the page, a spot that might be a few screens down the "linked-to" page. According to the wiki syntax page I am told I can do it with:
[[syntax#internal|this section]] which would link me to "This section" on another page.
What does the phrase "syntax#internal" mean?
If I'm on Page A and want to link to Section 12 of Page B what would be an example of "syntax#internal"?
Thanks for the help.
Darrel
koko
hi,
[[namespace1:namespace2:namespace3:Pagename#sectiontitle|The name you would like the link to have]]
[[namespace:page_B#section 12|Section 12]]
blackfog
Koko, is an underscore "_" not needed anymore?
[[namespace:page_B#section_12|Section 12]]
I have good results with it. ;)
BlackFog
koko
hi,
I never use section-links, so I have no idea whether you have put an underscore in the section title :-D
I'm glad you've got what you wanted ;-)
andi
BlackFog wrote
Koko, is an underscore "_" not needed anymore?
[[namespace:page_B#section_12|Section 12]]
In fact it is not needed. In your special case above the following would result in exactly the same link with much less to write:
[[namespace:page_B#Section 12]]
DokuWiki automatically uses the Section name as link title. For the link itself the anchor is cleaned automatically, too ("Section 12" -> "section_12").
gezeke
Hi there--
I just stumbled across this discussion and it intrigues me greatly as creating internal links to a specific section of another page has been baffling me. I've got the exact syntax recommended below, and the links work perfectly... sometimes. Sometimes the link just redirects me to the top of the page instead of to a specific section. Is there anything I'm missing?
blackfog
Maybe if the page is not long enough and can't be scrolled any further? Otherwise I have no idea why this could happen...
BlackFog
epp
I have a problem that I cannot get this kind of links to work if the link starts with a number or is not english. I mean
[[namespace:page#32nd]]
will not jump to the 32nd section. It will go to the right page. The same happens if I use greek language for the text.
Is this a dokuwiki issue or a browser issue? I use firefox.
epp
I see that it is a Dokuwiki issue. I mean the source code generated is:
<h1><a name="nd" id="nd">32nd</a></h1>
I also tested with a plan html file and there doesn't seem to be a restriction on what name one can give. I don't know about XHTML, but I don't see why it should be a problem.
Is this then a bug that I should submit a report on?
koko
hi,
Bugs has to be submitted on:
http://bugs.splitbrain.org/
Thanks for revealing the issue :-D
epp
I found the problem. I'll report it. A call to headerToLink is missing in the internallink function.
epp
There is a bug in dokuwiki that most likely is the cause of this. A solution has been filed so I guess it should be fixed soon.
koko
Hhmm, maybe it is already fixed in the dev-version. Do you use this version? If not, can you describe how i can see whether it is already fixed or not?
epp
I use the debian version, not sure it is the dev or not. Anyway, check the file: inc/parser/xhtml.php
In the function: function internallink($id, $name = NULL, $search=NULL,$returnonly=false)
A bit down in this function it says (if not fixed):
//keep hash
if($hash) $link['url'].='#'.$hash;
it should, IMH :rolleyes: be:
//keep hash
if($hash) {
$hash = $this->_headerToLink($hash);
$link['url'].='#'.$hash;
}
This makes the links work. :-)
koko
hi,
I tried it in my wiki (i use the dev), but it hasn't been fixed yet... and if I try your fix, I can't get it working either
epp
Where can I find the dev version? I'm using the latest stable, but in the download section there is no link to development versions as I can see...
But are you sure you purged your cache files? What did you test with so I can test the same here.
koko
epp
Can you test this for me? Given you changed xhtml.php like I described before, if you also change the _headerToLink function to this:
[m]
function _headerToLink($title,$create=false) {
//$title = str_replace(':','',cleanID($title,true)); //force ASCII
//$title = ltrim($title,'0123456789._-');
//if(empty($title)) $title='section';
//if($create){
// make sure tiles are unique
//$num = '';
//while(in_array($title.$num,$this->headers)){
//($num) ? $num++ : $num = 1;
//}
//$title = $title.$num;
//$this->headers[] = $title;
//}
return rawurlencode(utf8_strtolower($title));
}
[/m]
Does this work for your case? It works for my cases.
epp
OK I see that sections with spaces doesn't work.
Add:
[m]
$title = str_replace(' ','_', $title);
[/m]
before the return in the code above.
Interwiki links don't work either. It seems there need to be some rework done on the whole #linking... I'll get on the mailinglist.