With the addition of templates and the updated parser adding a sidebar no longer requires modification of any main dokuwiki scripts - only the local configuration file (local.php) and the template you are using.
I have been using your techniques for making a sidebar - thanks. I suggest however not to include code in local.php - I think it should only contain configuration overwrites. Rather, additional code (that logically belongs to a specific template) can be put in a file in the template directory and included in the main.php template file. — Jan Decaluwe (who was unable to register - a mail problem was reported).
Point taken, it was a hang over from the first implementation (before templates). I don't think the code actually belongs in the template file either. I have asked Andi via feature request if the sidebar function can make it into the current development version. I will also, post a feature request for a plug-in folder and configuration variable. Then the template file, main.php can include the sidebar function from a known place$conf['plugin_dir']."/sidebar.php". In the mean-time I will separate out the function into its own file and modify main.php to include it.
The html_navigate() function does all the work. It will display a navigation sidebar contained by
<div id='wiki_navigate'></div>.
If you are not using the default Dokuwiki template, you must specify the name of the folder containing your template in the local.php file.
$conf['template'] = 'your template'; //override the default dokuwiki template, if required.
*/ @require_once('tplfn_sidebar.php'); // line to add ?>
<div class="page"> (approx. line#88)<div id="wiki_navigate"><? html_navigate();?></div>
tpl/default/layout.css, for more information refer styles - layout below.tpl/default/design.css, for more information refer styles - design below./tpl/default folder, the name you give this folder is the name of your template (e.g. sidebar)tpl/your template/main.phpconf/local.php to the name of your template (e.g. $conf['template'] = 'sidebar';)tpl/default/layout.css, for more information refer styles - layout below.tpl/your template/design.css, for more information refer styles below.@require_once('tplfn_sidebar.php');
<div id="mynavigationtemplate"><? html_navigate(); ?></div>
#mynavigationtemplate). For more information refer styles below.
Place the following code in a file called tplfn_sidebar.php within the folder containing your template. There must be no blank lines before the opening <?php or after the closing ?>.
<?php /* * Provide navigation sidebar functionality to Dokuwiki Templates * * This is not currently part of the official Dokuwiki release * * @link http://wiki.jalakai.co.uk/dokuwiki/doku.php?id=tutorials:dev:navigation_sidebar * @author Christopher Smith <chris@knowledge.tv> */ $conf['navigate'] = 'navigate'; //name of navigation page // recursive function to establish best navigate file to be used function getNavigateFN($ns, $file) { // check for wiki page = $ns:$file (or $file where no namespace) $nsFile = ($ns) ? "$ns:$file" : $file; if (file_exists(wikiFN($nsFile))) return $nsFile; // remove deepest namespace level and call function recursively // no namespace left, exit with no file found if (!$ns) return ''; $i = strrpos($ns, ":"); $ns = ($i) ? substr($ns, 0, $i) : false; return getNavigateFN($ns, $file); } function html_navigate() { global $ID; global $REV; global $conf; // save globals $saveID = $ID; $saveREV = $REV; // discover file to be displayed in navigation sidebar $fileNavigate = ''; if (isset($conf['navigate'])) { $fileNavigate = getNavigateFN(getNS($ID), $conf['navigate']); } // determine what to display if ($fileNavigate) { $ID = $fileNavigate; $REV = ''; print p_wiki_xhtml($ID,$REV,false); } else { html_index('.'); } // close navigate <div> and restore globals $ID = $saveID; $REV = $saveREV; } ?>
The style to control where on the screen your navigation page will be displayed. If you have followed either methods 1 or 2 above then you can choose from one of the examples shown
note: width of sidebar and width of div.page should add to nearly (but less than) 100%. A fixed pixel width sidebar would require extra markup to work flawlessly in IE.
#wiki_navigate {float:left; width:20%; margin:0; padding:2px; border-width: 0;} #wiki_navigate {background-color: #ffffff; border-width:1px 2px 2px 1px; border-style:solid; border-color:#999999} /* fix to contain effects of clears within div.page (so sidebar isn't cleared) */ div.page {float:left; width: 76%; margin:0; margin-left:2%;}
note: the width assigned to the sidebar is the same as the new margin-left value for .dokuwiki.
/* make some space in the main dokuwiki <div> */ .dokuwiki {margin-left:180px; border-left: 1px solid black;} #wiki_navigate {position:absolute; top:0; left:0; width:180px;}
The navigation sidebar is really just an ordinary dokuwiki page. If you make no style rules concerning it, it will display in the same fashion as your normal pages do. The following are the style changes I use, primarily reduced font-sizes and reduced margin indentations.
#wiki_navigate {font-size:10px;} #wiki_navigate a {color: green;} #wiki_navigate a.wikilink2 {color:#999999;} #wiki_navigate a.wikilink2:hover {text-decoration:none; cursor:default;} #wiki_navigate h1 {font-size:140%; margin-left: 2px; padding-left: 2px; font-weight:bold; padding-bottom:0; background-color:#99cc99;} #wiki_navigate h2 {font-size:120%; margin-left: 4px; font-weight:bold; padding-bottom:0;} #wiki_navigate h3 {font-size:120%; margin-left: 8px; font-weight:normal; padding-bottom:0;} #wiki_navigate h4 {font-size:100%; margin-left: 12px; font-weight:bold; padding-bottom:0;} #wiki_navigate h5 {font-size:100%; margin-left: 16px; font-weight:normal; padding-bottom:0;} #wiki_navigate .toc {display:none;}