From 9a2e250ac50cb5571b81b8d005a1f1edf7b8e17f Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Sat, 7 Jan 2012 14:11:47 +0100
Subject: [PATCH] make sure that sidebar TOCs won't interfere with page TOCs

This could happen if a sidebar is rendered before the page (populating
$TOC) and the page itself had no own TOC (no headers).
---
 inc/template.php | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/inc/template.php b/inc/template.php
index c70e407d6..476ef74a3 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1354,9 +1354,12 @@ function tpl_license($img='badge',$imgonly=false,$return=false){
  */
 function tpl_include_page($pageid,$print=true){
     global $ID;
-    $oldid = $ID;
+    global $TOC;
+    $oldid  = $ID;
+    $oldtoc = $TOC;
     $html = p_wiki_xhtml($pageid,'',false);
-    $ID = $oldid;
+    $ID  = $oldid;
+    $TOC = $oldtoc;
 
     if(!$print) return $html;
     echo $html;
-- 
GitLab