Skip to content

Commit

Permalink
Removed tpl_sidebar() to avoid fatal errors in other templates
Browse files Browse the repository at this point in the history
Replaced it by the old tpl_include_page() and made it more flexible by adding a boolean $propagate parameter.
(It's false by default for backwards compatibility reasons. Should it rather be true? That would probably be what most users want.)
  • Loading branch information
selfthinker committed Oct 6, 2012
1 parent c973a9c commit 835dfca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
18 changes: 5 additions & 13 deletions inc/template.php
Expand Up @@ -1465,14 +1465,17 @@ function tpl_license($img = 'badge', $imgonly = false, $return = false, $wrap =
}

/**
* Includes the rendered XHTML of a given page
* Includes the rendered HTML of a given page
*
* This function is useful to populate sidebars or similar features in a
* template
*/
function tpl_include_page($pageid, $print = true) {
function tpl_include_page($pageid, $print = true, $propagate = false) {
global $ID;
global $TOC;

if ($propagate) $pageid = page_findnearest($pageid);

$oldid = $ID;
$oldtoc = $TOC;
$html = p_wiki_xhtml($pageid, '', false);
Expand All @@ -1484,17 +1487,6 @@ function tpl_include_page($pageid, $print = true) {
return $html;
}

/**
* Include the sidebar, will check current namespaces first
*/
function tpl_sidebar($print = true) {
global $conf;

$sidebar = page_findnearest($conf['sidebar']);
if($sidebar) return tpl_include_page($sidebar, $print);
return '';
}

/**
* Display the subscribe form
*
Expand Down
2 changes: 1 addition & 1 deletion lib/tpl/dokuwiki/main.php
Expand Up @@ -42,7 +42,7 @@ class="dokuwiki site mode_<?php echo $ACT ?> <?php echo ($showSidebar) ? 'showSi
<div class="content">
<?php tpl_flush() ?>
<?php tpl_includeFile('sidebarheader.html') ?>
<?php tpl_sidebar() ?>
<?php tpl_include_page($conf['sidebar'], 1, 1) ?>
<?php tpl_includeFile('sidebarfooter.html') ?>
</div>
</div></div><!-- /aside -->
Expand Down

0 comments on commit 835dfca

Please sign in to comment.