NestedSidebarIncludes
<< | Cookbook-V1 | >>
Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.
Goal
Use a template to include a sidebar on all pages that, in turn, can include other pages. This was required to facilitate building the sidebar out of many separate "toolkits".
Secondary goal was to make it easy to include an "edit" link on the sidebar which can be used to easily edit the sidebar rather than the enclosing page.
Solution
Attach:wikiinc.php includes the two functions wikiinc and wikiinctest described below.
Put this file in your local
directory and include a line like this in your config.php
file...
include_once('local/wikiinc.php');
Discussion
I created two functions modeled on those found in pmwiki.php. They both draw on PrintWikiPage, but do slightly different things with the resulting page. The cool thing about PrintWikiPage is that it steps through a list of pages to find the one that exists, then presents that page. It is called from a template with code like...
<!--wiki:$Group.SideBar Main.SideBar-->
I needed a sidebar built from a bunch of [[include:Group.ToolKit]]
kind of sections. Unfortunately the wiki
call above does not process the page text, so I needed a function which includes not just the page text, but the "processed" page text. I can now do this with my "wikiinc" function, invoked from a template like this...
<!--function:wikiinc $Group.SideBar Main.SideBar-->
My "wikiinctest" simply prints the page name instead of the page text. This makes it easy to include something like an edit button from the template with code like...
<a href='$ScriptUrl/<!--function:wikiinctest $Group.SideBar Main.SideBar-->?action=edit'>Edit</a>
See Also
Many of the skins have sidebars, but I didn't find any building them out of page components on the fly.
History
None yet.
Comments & Bugs
I don't know what dire consequences there may be to using portions of ProcessTextDirectives code at this stage of page rendering. But it seems to work just like I want it to. Can anyone comment?
Pm has since shared with me a way to create the edit button right in the sidebar text [[ThisWiki:/MyGroup/MySideBar?action=edit Edit]]
, so this "wikiinctest" function is less critical.
Contributors
Copyright
Probably GPL, since it is mostly Pm's code moved around in questionable ways! pmwiki-2.4.4 -- Last modified by {{Pm}}