Table of Contents
Getting rid of underscores in displayed links
Consider config option useheading before reading the rest.
Change title of internallinks
It will replace underscores in links in wikipages. When people copy this linktitles on a page and use them in their internallinks, that's fine, because DokuWiki interpret spaces as underscores.
Modify only indicated lines.
Index: inc/parser/renderer.php =================================================================== --- inc/parser/renderer.php +++ inc/parser/renderer.php function _simpleTitle($name){ global $conf; //if there is a hash we use the ancor name only list($name,$hash) = explode('#',$name,2); if($hash) return $hash; if($conf['useslash']){ $name = strtr($name,';/',';:'); }else{ $name = strtr($name,';',':'); } - return noNSorNS($name); + $name = noNSorNS($name); + + // replace '_' with ' ' + return strtr($name,'_',' '); }
Old format_pretty_ref() for changing DokuWiki pagetitles
Clean pagetitles without 'useheading'
Thanks for the great tips on this page! I wanted a few things for my titles: to replace underscores by spaces, add an initial capital and show an abbreviated title when using namespaces. I disliked the idea of using Useheading, so this is what I did:
Add this at the bottom of inc/template.php:
function format_pretty_ref($name){ if(strstr($name, ':') == ''){ return utf8_ucfirst(strtr($name,'_',' ')); }else{ return utf8_ucfirst(substr(strrchr(strtr($name,'_',' '), ':'), 1 )); } }
Wrap the function around tpl_pagetitle in lib/tpl/[yourtheme]/main.php or add it to tpl_pagetitle in inc/template.php
eg. print(format_pretty_ref(tpl_pagetitle($ID,true)))
e.g. 'wiki:namespace:page_title' becomes 'Page title'
– jayjay 2008-05-08
Update for namespace start pages
This one may even be better. The standard start page of a namespace is 'namespace:start'. The above code will show 'Start' as the pagetitle of every namespace start page. The code below will show the namespace title instead of the word 'start'.
eg. 'wine_bottles:french_wine' becomes 'French wine' ; 'wine_bottles:start' becomes 'Wine bottles'
function format_pretty_ref($name){ global $conf; if(strstr($name, ':') == ''){ return utf8_ucfirst(strtr($name,'_',' ')); }else{ if(substr(strrchr($name, ':'), 1 ) == $conf['start']) { $name = substr($name, 0, strlen($name) - strlen($conf['start']) - 1); if(strstr($name, ':') == ''){ return utf8_ucfirst(strtr($name,'_',' ')); }else{ return utf8_ucfirst(substr(strrchr(strtr($name,'_',' '), ':'), 1 )); } }else{ return utf8_ucfirst(substr(strrchr(strtr($name,'_',' '), ':'), 1 )); } } }
– jayjay 2008-05-08
Only ':' -> '|' and '_' ->' '
function format_pretty_ref($name){ return utf8_ucwords(str_replace(":", " | ", strtr($name,'_',' '))); }