How To: Add a Sidebar to an existing Template

These instructions assume you have a basic understanding of php, html & css and understand how to successfully create your own Dokuwiki template.

  1. Add the two sidebar files, tplfn_sidebar.php & sidebar.css, to your template folder.
  2. Make the following additions/changes to your template's main.php file:
    • Near the top of your template's main.php file and within the <?php ?> tags add the following:
      // include functions that provide sidebar functionality
      @require_once('tplfn_sidebar.php');
       
      // determine the sidebar class
      $sidebar_class = "sidebar_{$conf['sidebar']['layout']}_{$conf['sidebar']['orientation']}";
    • Within the <head> element and adjacent to any existing style sheet <link> add the following line:
        <link rel="stylesheet" media="screen" type="text/css" href="<?php echo DOKU_TPL; ?>sidebar.css" />
    • Change the <body> tag to
      <body class="<?php echo $sidebar_class; ?>">

      Note: If your <body> tag already has a class modify the body tag has to look similar to:

      <body class="myclass <?php echo $sidebar_class; ?>">

      .

    • At the appropriate place within your template add the following line to display the sidebar:
      <div id="sidebar"><?php tpl_sidebar_content(); ?></div>

      The sidebar comes styled so that the above line can be placed between the closing </div> of div.content and <div class='clearer'>&nbsp;</div>

      • i had to add
        <div id="sidebar"><?php tpl_sidebar(); ?></div>

        instead to make it work

  3. alter the sidebar styles as desired.
 
tutorials/addsidebar.txt · Last modified: 2008/04/14 04:51 by 98.224.140.68
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki