TrackingMenu

Summary: A sidebar menu tracking the current page
Version:
Prerequisites:
Status:
Maintainer:
Categories: Layout, Administration

Goal

A sidebar menu tracking the current page

Features

  • No JavaScript
  • No custom markups
  • CSS and WikiStyles compatible

Solution

Drop tmenu.phpΔ somewhere in the PmWiki cookbook/ directory (you may have to create it).

Add the following line to local/config.php:

include_once("cookbook/tmenu.php");

Use

Decorate your existing sidebar menu with (:tmenu:) and (:tmenuend:) directives, then define %tmenuitem% and %tmenucurrent% styles using CSS or regular WikiStyles.

From the technical point of view, (:tmenu:) adds a <div class="tmenu"> around the menu which can be tuned up with CSS. List items containing links are marked with %tmenuitem% style. Item corresponding to the current page gets %tmenucurrent% style.

It does not affect any other lists outside (:tmenu:) blocks.

Example (copy and paste to your page, it won't work here)


%define=tmenucurrent color=yellow bgcolor=gray apply=item%
(:tmenu:)
* [[Main/Home Page]]
* [[Main/WikiSandbox]]
* [[PmWiki/Installation | Download and Install]]
* [[PmWiki/Tips For Editing]]
* [[PmWiki/Documentation Index]]
* [[PmWiki/FAQ]]
* [[PmWiki/PmWikiPhilosophy]]
* [[PmWiki/Release Notes]]
* [[PmWiki/ChangeLog]]
(:tmenuend:)

(:tmenu:)

(:tmenuend:)

Discussion

Pmwiki adds to all links in the Sidebar either class='wikilink' or class='urllink', exept the link to the current page, which gets a class='selflink'. with these classes one can easily style the sidebar links and emphasise the current page, using in pub/css/local.css, or the skin's css file, or via a &HTMLStylesFmt[] = " ...."; declaration, statements like #wikileft.selflink { ... } or #sidebar.selflink { ... } (depending on the skin template). So I don't see the point of the tmenu.php recipe. It seems to do something which is already done by default. HansB April 15, 2005, at 10:41 AM

Basically you're right, I could say my intention was to provide more or less complete solution, but actually I just didn't know about that 'selflink' feature :-) We really need some good documentation. mikei June 13, 2005

Mateusz: A solution based also on HansB's response to my similar question, but tweaked a bit (so that self-link is marked, and no longer a link) is to put the following line in local/config.php:

  $LinkPageSelfFmt = "<span class='selflink'>\$LinkText</span>"; 

Author