Removing Underscores

…from displayed links

Note regarding 2005-May-07 version of Dokuwiki

The below changes only apply to non template versions of dokuwiki, that is versions prior to 2005-May-07 release. The most recent versions have a new configuration setting $conf['useheading'] that allow wiki links to be replaced by the first header on the page itself. At present (2005-May-31) that is only a partial solution. For details on extending that solution refer Feature Request #354

Chris 2005-May-31

Those underscores really bug me so…

in inc/format.php, function format_link_build() at about line #19

  $ret .= '>';
  $ret .= strtr($link['name'],'_',' ');   // altered from $ret .= $link['name'];
  $ret .= '</a>';

which takes care of recent, search, index and backlinks pages

in inc/html.php function html_breadcrumbs() at about line #151

//  orig. line commented, followed by new line
//  .noNS($crumb).  ==> becomes ==> .str(noNS($crumb), '_', ' ').
//    print '<a href="'.wl($crumb).'" class="breadcrumbs" onclick="return svchk()" onkeypress="return svchk()" title="'.$crumb.'">'.noNS($crumb).'</a>';
 
  print '<a href="'.wl($crumb).'" class="breadcrumbs" onclick="return svchk()" onkeypress="return svchk()">'.strtr($crumb,'_',' ').'</a>';

which takes care of the breadcrumbs

in inc/html.php function html_header() at about line #308

// new line only shown, change is to process $ID through strtr ==>  strtr($ID,'_',' ')
    <div class="pagename">
      [[<a href="<?php   echo wl($ID,'do=backlink')?>" onclick="return svchk()" onkeypress="return svchk()"><?php  echo strtr($ID,'_',' '); ?></a>]]
    </div>

and finally thats the backlink (eg. [[current page]]) button done.
- Chris

How would this work in the new template system?

/**
 * Print the breadcrumbs trace
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 */
function tpl_breadcrumbs(){
  global $lang;
  global $conf;

  //check if enabled
  if(!$conf['breadcrumbs']) return;

  $crumbs = breadcrumbs(); //setup crumb trace

  //reverse crumborder in right-to-left mode
  if($lang['direction'] == 'rtl') $crumbs = array_reverse($crumbs,true);

  //render crumbs, highlight the last one
  print $lang['breadcrumb'].':';
  $last = count($crumbs);
  $i = 0;
  foreach ($crumbs as $id => $name){
    $i++;
    print ' <span class="bcsep">&raquo;</span> ';
    if ($i == $last) print '<span class="curid">';
    tpl_link(wl($id),$name,'class="breadcrumbs" title="'.$id.'"');
    if ($i == $last) print '</span>';
  }
}

- adraeus

Adraeus, new system doesn't require changes for breadcrumbs, use $conf['useheading']. I will publish changes required to extend useheading to search page, recent changes page and backlink button shortly. They are very straightforward. Check out this site (dev version) to see them working.
Chris 2005-05-31
 
tutorials/removing_underscores.txt · Last modified: 2010/05/31 16:21 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki