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

Array
(
    [post_max_size] => 64M
    [$_POST keys] => 
    [$_REQUEST keys] => n
    [$_SERVER] => Array
        (
            [CONTEXT_DOCUMENT_ROOT] => /home/pmwiki/public_html
            [CONTEXT_PREFIX] => 
            [DOCUMENT_ROOT] => /home/pmwiki/public_html
            [GATEWAY_INTERFACE] => CGI/1.1
            [HTTPS] => on
            [HTTP_ACCEPT] => */*
            [HTTP_ACCEPT_ENCODING] => gzip, br, zstd, deflate
            [HTTP_COOKIE] => imstime=1777497045; PHPSESSID=og9nkbnfha5l34nftvcaa0fd63
            [HTTP_HOST] => www.pmwiki.org
            [HTTP_REFERER] => http://www.pmwiki.org/wiki/Cookbook/TrackingMenu
            [HTTP_USER_AGENT] => Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
            [HTTP_X_HTTPS] => 1
            [PATH] => /bin:/usr/bin
            [PHP_INI_SCAN_DIR] => /opt/cpanel/ea-php70/root/etc:/opt/cpanel/ea-php70/root/etc/php.d:.
            [QUERY_STRING] => n=Cookbook%2fTrackingMenu
            [REDIRECT_HTTPS] => on
            [REDIRECT_QUERY_STRING] => n=Cookbook%2fTrackingMenu
            [REDIRECT_SCRIPT_URI] => https://www.pmwiki.org/wiki/Cookbook/TrackingMenu
            [REDIRECT_SCRIPT_URL] => /wiki/Cookbook/TrackingMenu
            [REDIRECT_SSL_TLS_SNI] => www.pmwiki.org
            [REDIRECT_STATUS] => 200
            [REDIRECT_UNIQUE_ID] => afJz6Tx_gK_Ww16LiOiKgwAAARc
            [REDIRECT_URL] => /wiki/Cookbook/TrackingMenu
            [REMOTE_ADDR] => 216.73.216.31
            [REMOTE_PORT] => 22882
            [REQUEST_METHOD] => GET
            [REQUEST_SCHEME] => https
            [REQUEST_URI] => /wiki/Cookbook/TrackingMenu
            [SCRIPT_FILENAME] => /home/pmwiki/public_html/index.php
            [SCRIPT_NAME] => /index.php
            [SCRIPT_URI] => https://www.pmwiki.org/wiki/Cookbook/TrackingMenu
            [SCRIPT_URL] => /wiki/Cookbook/TrackingMenu
            [SERVER_ADDR] => 23.254.203.248
            [SERVER_ADMIN] => webmaster@pmwiki.org
            [SERVER_NAME] => www.pmwiki.org
            [SERVER_PORT] => 443
            [SERVER_PROTOCOL] => HTTP/1.1
            [SERVER_SIGNATURE] => 
            [SERVER_SOFTWARE] => Apache
            [SSL_TLS_SNI] => www.pmwiki.org
            [TZ] => America/Los_Angeles
            [UNIQUE_ID] => afJz6Tx_gK_Ww16LiOiKgwAAARc
            [PHP_SELF] => /index.php
            [REQUEST_TIME_FLOAT] => 1777497065.3256
            [REQUEST_TIME] => 1777497065
            [argv] => Array
                (
                    [0] => n=Cookbook%2fTrackingMenu
                )

            [argc] => 1
        )

)