From 31e187f85698a8f8dfbf4705761517c05cd6aab6 Mon Sep 17 00:00:00 2001 From: Sean Coates <sean@caedmon.net> Date: Fri, 24 Feb 2006 16:56:31 +0100 Subject: [PATCH] hierarchical breadcrumbs This patch adds optional hierarchical breadcrumbs. This was discussed last december in http://www.freelists.org/archives/dokuwiki/12-2005/msg00112.html and followups. Many people where in favour of this. darcs-hash:20060224155631-21b7e-10f25b7bdf60120ec99850afefd4d1662c5b87aa.gz --- conf/dokuwiki.php | 1 + inc/lang/en/lang.php | 1 + inc/template.php | 29 +++++++++++++++++++++-------- lib/tpl/default/main.php | 6 ++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php index afdbdf3a0..04b0abe0b 100644 --- a/conf/dokuwiki.php +++ b/conf/dokuwiki.php @@ -25,6 +25,7 @@ $conf['template'] = 'default'; //see tpl directory $conf['fullpath'] = 0; //show full path of the document or relative to datadir only? 0|1 $conf['recent'] = 20; //how many entries to show in recent $conf['breadcrumbs'] = 10; //how many recent visited pages to show +$conf['youarehere'] = 0; //show "You are here" navigation? 0|1 $conf['typography'] = 1; //convert quotes, dashes and stuff to typographic equivalents? 0|1 $conf['htmlok'] = 0; //may raw HTML be embedded? This may break layout and XHTML validity 0|1 $conf['phpok'] = 0; //may PHP code be embedded? Never do this on the internet! 0|1 diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index f3c7c3dbe..1a4308125 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -111,6 +111,7 @@ $lang['yours'] = 'Your Version'; $lang['diff'] = 'show differences to current version'; $lang['line'] = 'Line'; $lang['breadcrumb'] = 'Trace'; +$lang['youarehere'] = 'You are here'; $lang['lastmod'] = 'Last modified'; $lang['by'] = 'by'; $lang['deleted'] = 'removed'; diff --git a/inc/template.php b/inc/template.php index 63e90118d..5d085605d 100644 --- a/inc/template.php +++ b/inc/template.php @@ -535,12 +535,12 @@ function tpl_breadcrumbs(){ /** * Hierarchical breadcrumbs * - * This code was suggested as replacement for the usual breadcrumbs - * trail in the Wiki and was modified by me. + * This code was suggested as replacement for the usual breadcrumbs. * It only makes sense with a deep site structure. * * @author Andreas Gohr <andi@splitbrain.org> * @author Nigel McNie <oracle.shinoda@gmail.com> + * @author Sean Coates <sean@caedmon.net> * @link http://wiki.splitbrain.org/wiki:tipsandtricks:hierarchicalbreadcrumbs * @todo May behave strangely in RTL languages */ @@ -549,16 +549,22 @@ function tpl_youarehere(){ global $ID; global $lang; + //check if enabled + if(!$conf['youarehere']) return; $parts = explode(':', $ID); - // Perhaps a $lang['tree'] could be defined? "Trace" isn't too appropriate - //print $lang['tree'].': '; - print $lang['breadcrumb'].': '; + print $lang['youarehere'].': '; //always print the startpage - if( $a_part[0] != $conf['start'] ) - tpl_link(wl($conf['start']),$conf['start'],'title="'.$conf['start'].'"'); + if( $a_part[0] != $conf['start']){ + if($conf['useheading']){ + $pageName = p_get_first_heading($conf['start']); + }else{ + $pageName = $conf['start']; + } + tpl_link(wl($conf['start']),$pageName,'title="'.$pageName.'"'); + } $page = ''; foreach ($parts as $part){ @@ -569,7 +575,14 @@ function tpl_youarehere(){ $page .= $part; if(file_exists(wikiFN($page))){ - tpl_link(wl($page),$part,'title="'.$page.'"'); + if($conf['useheading']){ + $pageName = p_get_first_heading($page); + $partName = $pageName; + }else{ + $pageName = $page; + $partName = $part; + } + tpl_link(wl($page),$partName,'title="'.$pageName.'"'); }else{ // Print the link, but mark as not-existing, as for other non-existing links tpl_link(wl($page),$part,'title="'.$page.'" class="wikilink2"'); diff --git a/lib/tpl/default/main.php b/lib/tpl/default/main.php index 01dd60d66..1f4940327 100644 --- a/lib/tpl/default/main.php +++ b/lib/tpl/default/main.php @@ -64,6 +64,12 @@ </div> <?php }?> + <?php if($conf['youarehere']){?> + <div class="breadcrumbs"> + <?php tpl_youarehere() ?> + </div> + <?php }?> + </div> <?php flush()?> -- GitLab