NestedSidebarIncludes

<< | Cookbook-V1 | >>

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


created by efc on 040324, but I have no idea if just adding this page is the right thing to do

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".

PmWiki versions 0.6.18 and later now support the use of (:include :) statements within sidebar pages.

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.3.33 -- Last modified by {{Pm}}

from IP: 85.171.160.186 ip should be disabled by default for security reasons