Sidebar Source Listing

The majority of the files included with the template are the files that come with Dokuwiki's default template. Of the three remaining files, two are new (tplfn_sidebar.php & sidebar.css) and one is changed (main.php). Complete listings of these three files are given below.

sidebar/tplfn_sidebar.php

<?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@jalakai.co.uk>
 */
 
// sidebar configuration settings
$conf['sidebar']['enable'] = 1;               // 1 or true to enable sidebar functionality, 0 or false to disable it
$conf['sidebar']['page'] = 'sidebar';         // name of sidebar page
$conf['sidebar']['layout'] = 'inside';        // inside (between button bars) or outside (full height of dokuwiki)
$conf['sidebar']['orientation'] = 'left';     // left or right
 
// determine the sidebar class
$sidebar_class = "sidebar_{$conf['sidebar']['layout']}_{$conf['sidebar']['orientation']}";
 
// recursive function to establish best sidebar file to be used
function getSidebarFN($ns, $file) {
 
	// check for wiki page = $ns:$file (or $file where no namespace)
	$nsFile = ($ns) ? "$ns:$file" : $file;
	if (file_exists(wikiFN($nsFile)) && auth_quickaclcheck($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 getSidebarFN($ns, $file);
}
 
// display the sidebar
function tpl_sidebar() {
	global $ID, $REV, $conf;
 
	// save globals
	$saveID = $ID;
	$saveREV = $REV;
 
	// discover file to be displayed in navigation sidebar	
	$fileSidebar = '';
 
	if (isset($conf['sidebar']['page'])) {
		$fileSidebar = getSidebarFN(getNS($ID), $conf['sidebar']['page']);
	}
 
	// determine what to display
	if ($fileSidebar) {
		$ID = $fileSidebar;
		$REV = '';
		print p_wiki_xhtml($ID,$REV,false);
	}
	else {
		html_index('.');
	}
 
	// restore globals
	$ID = $saveID;
	$REV = $saveREV;
}
 
if (!function_exists('tpl_pagename')) {
 
	require_once(DOKU_INC.'inc/parserutils.php');
 
    /**
     * Returns the name of the given page (current one if none given).
     *
     * If useheading is enabled this will use the first headline else
     * the given ID is printed.
     *
     * based on tpl_pagetitle in inc/template.php
     */
    function tpl_pagename($id=null){
      global $conf;
      if(is_null($id)){
        global $ID;
        $id = $ID;
      }
 
      $name = $id;
      if ($conf['useheading']) {
        $title = p_get_first_heading($id);
        if ($title) $name = $title;
      }
      print hsc($name);
    }
 
}
 
?>

sidebar/sidebar.css

/**
 * Extra styles for sidebar template
 *
 * @author Christopher Smith <chris@jalakai.co.uk>
 */
 
/* dokuwiki containers & styles */
 
@media screen {
 
/* sidebar orientation and position */
#sidebar {
	width:20%; 
	margin:0; 
	padding:0;
}
 
.sidebar_inside_left #sidebar {
	float:left; 
}
 
.sidebar_inside_right #sidebar {
	float:right; 
}
 
.sidebar_inside_left .page, .sidebar_inside_left .meta {
	float:right; 
	width:78%; 			/* also see IE Win fix below */
	margin-right: 1%;
	margin-left:0;
}
 
.sidebar_inside_right .page, .sidebar_inside_right .meta {
	float:left; 
	width:78%; 
	margin-left: 1%;
	margin-right: 0;
}
 
.sidebar_outside_left #sidebar {
	position:absolute; 
	top:0; 
	left:0;
}
 
.sidebar_outside_right #sidebar {
	position:absolute; 
	top:0; 
	right:0;
}
 
.sidebar_outside_left .dokuwiki {
	padding-left:21%;
}
 
.sidebar_outside_right .dokuwiki {
	padding-right:21%;
}
 
.sidebar_outside_left .footerinc {
	padding-left: 21%;
}
 
.sidebar_outside_right .footerinc {
	padding-right: 21%;
}
 
/* sidebar presentation */
/* the following three styles use a faux-column image to place a separating line 
   between the sidebar and dokuwiku */
.sidebar_outside_left .dokuwiki, .sidebar_inside_left .dokuwiki {
	background: url(images/sidebar-border.gif) repeat-y 20%;
}
 
.sidebar_outside_right .dokuwiki, .sidebar_inside_right .dokuwiki {
	background: url(images/sidebar-border.gif) repeat-y 80%;
}
 
/* hide the line where it passes through .stylehead */
.stylehead {
	background: white;
}
 
/* sidebar contents */
#sidebar {
	font-size:10px;
}
 
#sidebar a {
	color: green;
}
 
#sidebar a.wikilink2 {
	color:#999999;
}
 
#sidebar a.wikilink2:hover {
	text-decoration:none; 
	cursor:default;
}
 
#sidebar h1 {
	font-size:140%; 
	margin-left: 0px; 
	padding-left: 2px; 
	font-weight:bold; 
	padding-bottom:0; 
	background-color:#dee7ec;
}
#sidebar h2 {
	font-size:120%; 
	margin-left: 4px; 
	font-weight:bold; 
	padding-bottom:0;
}
#sidebar h3 {
	font-size:120%; 
	margin-left: 8px; 
	font-weight:normal; 
	padding-bottom:0;
}
#sidebar h4 {
	font-size:100%; 
	margin-left: 12px; 
	font-weight:bold; 
	padding-bottom:0;
}
#sidebar h5 {
	font-size:100%; 
	margin-left: 16px; 
	font-weight:normal; 
	padding-bottom:0;
}
#sidebar .toc {
	display:none;
}
 
/* reduced section indentation */
#sidebar div.level1 {margin-left: 2px;}
#sidebar div.level2 {margin-left: 6px;}
#sidebar div.level3 {margin-left: 10px;}
#sidebar div.level4 {margin-left: 14px;}
#sidebar div.level5 {margin-left: 18px;}
 
/* IE fixes (hide from IE Mac) \*/
 
* html .page .toc {height:1px}    /* General Dokuwiki fix. IE needs this to always display TOC contents \*/
* html pre {width:95%;}           /* General Dokuwiki fix - very important for Sidebar. IE needs this to get the overflow:auto style to kick in \*/
* html .stylehead {height:1px;}   /* Get IE in hasLayout mode to ensure the background covers the whole element \*/
 
* html .sidebar_inside_left .page, * .sidebar_inside_right .page, 
* html .sidebar_inside_left .meta, * .sidebar_inside_right .meta {
	width: 77%;                   /* IE needs extra gap to ensure #sidebar & .page float next to each other \*/
	overflow-x: auto;             /* IE proprietary property to prevent wide images in wiki page forcing sidebar down below wiki page \*/
                                  /* 'overflow-x:auto;' maybe replaced by 'overflow:auto;' to ensure template passes w3c validation \*/
}
 
/* (end IE Mac hiding) */
 
} /* end @media screen */
 
/* prevent the sidebar being included when printing wiki pages */
@media print {
	#sidebar {display:none;}
}

sidebar/main.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php 
/**
 * DokuWiki Sidebar Template
 * @author Christopher Smith <chris@jalakai.co.uk>
 *
 * This template is the Dokuwiki Default Template with
 * a few alterations
 *
 * @link   http://wiki.splitbrain.org/wiki:tpl:templates
 * @author Andreas Gohr <andi@splitbrain.org>
 */
 
// include functions that provide sidebar functionality
@require_once(dirname(__FILE__).'/tplfn_sidebar.php');
 
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $conf['lang']; ?>"
 lang="<?php echo $conf['lang']; ?>" dir="<?php echo $lang['direction']; ?>">
<head>
  <title><?php tpl_pagetitle(); ?> [<?php echo hsc($conf['title']); ?>]</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
  <?php tpl_metaheaders()?>
 
  <link rel="shortcut icon" href="<?php echo DOKU_BASE; ?>lib/images/favicon.ico" />
  <link rel="stylesheet" media="screen" type="text/css" href="<?php echo DOKU_TPL; ?>layout.css" />
  <link rel="stylesheet" media="screen" type="text/css" href="<?php echo DOKU_TPL; ?>design.css" />
  <?php if ($conf['sidebar']['enable']) { ?><link rel="stylesheet" type="text/css" href="<?php echo DOKU_TPL; ?>sidebar.css" /><?php } ?>
 
  <?php  if($lang['direction'] == 'rtl') {?>
  <link rel="stylesheet" media="screen" type="text/css" href="<?php echo DOKU_TPL; ?>rtl.css" />
  <?php  } ?>
 
  <link rel="stylesheet" media="print" type="text/css" href="<?php echo DOKU_TPL; ?>print.css" />
 
  <!--[if gte IE 5]>
  <style type="text/css">
    /* that IE 5+ conditional comment makes this only visible in IE 5+ */
    /* IE bugfix for transparent PNGs */
    //DISABLED   img { behavior: url("<?php echo DOKU_BASE; ?>lib/scripts/pngbehavior.htc"); }
  </style>
  <![endif]-->
 
  <?php /*old includehook*/ @include(dirname(__FILE__).'/meta.html')?>
</head>
 
<body<?php if ($conf['sidebar']['enable']) echo " class='$sidebar_class'"; ?>>
<?php /*old includehook*/ @include(dirname(__FILE__).'/topheader.html')?>
<div class="dokuwiki">
  <?php html_msgarea()?>
 
  <div class="stylehead">
 
    <div class="header">
      <div class="pagename">
        [[<?php tpl_link(wl($ID,'do=backlink'),tpl_pagename($ID)) ?>]]
      </div>
      <div class="logo">
        <?php tpl_link(wl(),$conf['title'],'name="top" accesskey="h" title="[ALT+H]"') ?>
      </div>
    </div>
 
    <?php /*old includehook*/ @include(dirname(__FILE__).'/header.html')?>
 
    <div class="bar" id="bar_top">
      <div class="bar-left" id="bar_topleft">
        <?php tpl_button('edit')?>
        <?php tpl_button('history')?>
      </div>
 
      <div class="bar-right" id="bar_topright">
        <?php tpl_button('recent')?>
        <?php tpl_searchform()?>&nbsp;
      </div>
    </div>
 
    <?php if($conf['breadcrumbs']){?>
    <div class="breadcrumbs">
      <?php tpl_breadcrumbs()?>
      <?php //tpl_youarehere() //(some people prefer this)?>
    </div>
    <?php }?>
 
  </div>
  <?php flush()?>
 
  <?php /*old includehook*/ @include(dirname(__FILE__).'/pageheader.html')?>
 
  <div class="page">
    <!-- wikipage start -->
    <?php tpl_content()?>
    <!-- wikipage stop -->
  </div>
  <?php if ($conf['sidebar']['enable']) { ?><div id="sidebar"><?php tpl_sidebar(); ?></div><?php } ?>
  <div class="clearer">&nbsp;</div>
 
  <?php flush()?>
 
  <div class="stylefoot">
 
    <div class="meta">
      <div class="user">
        <?php tpl_userinfo()?>
      </div>
      <div class="doc">
        <?php tpl_pageinfo()?>
      </div>
    </div>
 
   <?php /*old includehook*/ @include(dirname(__FILE__).'/pagefooter.html')?>
 
    <div class="bar" id="bar_bottom">
      <div class="bar-left" id="bar_bottomleft">
        <?php tpl_button('edit')?>
        <?php tpl_button('history')?>
      </div>
      <div class="bar-right" id="bar_bottomright">
        <?php tpl_button('subscription')?>
        <?php tpl_button('admin')?>
        <?php if (function_exists('updateprofile')) {tpl_button('profile');}?>
        <?php tpl_button('login')?>
        <?php tpl_button('index')?>
        <?php tpl_button('top')?>&nbsp;
      </div>
    </div>
 
  </div>
 
</div>
<?php /*old includehook*/ @include(dirname(__FILE__).'/footer.html')?>
<?php if (function_exists(tpl_indexerWebBug)) tpl_indexerWebBug(); ?>
</body>
</html>
 
tutorials/source.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