Summary: Inserts a portion of external table of contents into the page
Version: 2006-12-05
Prerequisites: pmwiki 2.1
Status: Alpha
Maintainer: NeARAZ
Categories: Markup, Menus


If you have a pseudo-hierarchical menus for your wiki, this helps inserting the relevant portion of the menu into the page. For any page, it inserts the contents that are "below" the current page.


  1. Put tocportion.phpΔ in your cookbook/ directory.
  2. Add include_once('cookbook/tocportion.php'); in your local/config.php.
  3. (optional) Set the default TOC page in local/config.php with $TocPortionDefaultPage = 'MyTocPage';
  4. Create the TOC page itself, which contains the bulleted TOC tree; one item per line. See example below.
  5. In any page where you want the TOC section, insert markup (:tocportion MyTocPage:). MyTocPage is the name of the page that contains TOC; if omitted then the default page is used.


Suppose the page MyTocPage contains this:
  * [[User Manual]]
  ** [[Basics]]
  *** [[Learning The Interface]]
  *** [[Doing Stuff]]
  ** [[Advanced]]
  *** [[Doing Even More Stuff]]
  ** [[FAQ]]
Then (:tocportion MyTocPage:) inserted into Basics page would yield the result of
  * [[Learning The Interface]]
  * [[Doing Stuff]]
The same markup inserted into User Manual page would result in
  * [[Basics]]
  ** [[Learning The Interface]]
  ** [[Doing Stuff]]
  * [[Advanced]]
  ** [[Doing Even More Stuff]]
  * [[FAQ]]

Release Notes

  • 2006-12-05 Initial "works for me" release.

Todo and gotchas

Right now it only supports bulleted lists for the TOC, with one item followed by the simplest link markup [[PageName]].

Should be expanded to numbered lists and more valid link markup types.


See also

Cookbook /
Accordion  lightweight Accordion javascript requiring no framework (stable)
AutoTOC  Unobtrusive Automatic Table of Contents links (stable)
HandyTableOfContents  Handy Client-side Table of Contents (stable)
NumberedHeaders  Display numbered headers, indented paragraphs and table of contents (Stable)
NumberedSections  Add section numbers on a page (stable)
PageTableOfContents  Adds a clickable table of contents to a page (Stable)
QuickPageTableOfContents  Adds a dropdown clickable table of contents to a page - client side processing (Stable)
SlimTableOfContents  Simple or Numbered Table of Contents, Compatible with SectionEdit Recipe (not working with php5.5)
PmWiki /


Alexander Heintz - 2008-10-28

added these lines starting at line 55 in order to handle slightly more complex link markup:

$p = strtok($m[2], "|");
$p = trim($p);
$p = str_replace('.', '/', $p);

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.