[Pmwiki-users] Removing sidebar if there's no SideBar-page

Christian Ridderström chr
Sun Feb 15 06:37:42 CST 2004


Hi

I want a default behaviour so that when there is no SideBar-page, the 
layout does not include space for an empty sidebar. Therefore I wrote the 
following function:

	function removeSideBarIfNoPageExists($side='left') {
	  global $DefaultGroup, $pagename, $WikiDir;

	  if(!MyPageExists(FmtPageName('$Group.SideBar', $pagename), $WikiDir) &&
	     !MyPageExists(FmtPageName('$DefaultGroup.SideBar', $pagename), $WikiDir))
	    $PageLayoutFmt['wiki'.$side] = '';
	}

It uses a modified version of PageExists() which I think should replace
the current PageExists().

	function MyPageExists($pagename, $dirs) {
	  global $WikiLibDirs,$PageFileFmt;

	  if(1 == func_num_args())
	    $dirs = $WikiLibDirs;
	  elseif(is_string($dirs))
	    $dirs = array($dirs);

	  $pagefile = FmtPageName($PageFileFmt,$pagename);
	  if (!$pagefile) return false;
	  foreach ($dirs as $dir) {
	    if (file_exists("$dir/$pagefile")) return true;
	  }
	  return false;
	}

In order to use this, just run this function after 'stdconfig.php' has
been included.

Unfortunately the above doesn't work in the sense that setting

	$PageLayoutFmt['wikileft']=''

doesn't help, the layout still has a big empty space to the left :-(

What's wrong?

/Christian        

-- 
Christian Ridderstr?m                           http://www.md.kth.se/~chr





More information about the pmwiki-users mailing list