WebMenu

<< | Cookbook-V1 | >>

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


=note This recipe is primarily for PmWiki 0.5. PmWiki version 0.6 can more easily incorporate menus through layout templates (see PmWiki/LayoutBasics).

Goal

Provide a menu to help navigate a large wiki.

Solution

Add a navigation menu. Based on the "WebMenu" from Twiki's GnuSkin. See it in action here and [(approve links) edit diff]. Both links are broken --Grieco

Attach:webmenu.php - source code (08-Sep-2003)

Installation

To use, copy the webmenu.php script to your local/ directory, then add the line:

   include_once("local/webmenu.php")

to your local.php.

Now load your wiki and create a new page named "WebMenu". Whatever you put on this page will appear in the navigation menu for that group. If you would like use the same menu for all groups, add the line:

    $DefaultWebMenu = "Main.WebMenu";

to your local.php, (before the include_once() line so that it is available to be used by webmenu.php), replacing "Main" with the name of the appropriate group if necessary. To hide the menu while printing or editing pages, you can do a conditional include, like this:

    if ($action=="browse") include_once("local/webmenu.php");

WebMenu is easiest to set up when used in conjunction with FlexLayout.

Discussion

I just uploaded a new version. It will now check for the existence of a WebMenu page before installing the hooks, preventing the big blank left margin on groups that do not use a menu. Also, instead of always including $DefaultGroup.WebMenu, I created a new global variable called $DefaultWebMenu, set the new installation instructions above. I think this clears up the biggest issues with the old version. Enjoy! -- JasonPerkins 29 Aug 2003

Access to wiki page

I modified webmenu.php such that it looks for $Group\WebMenu and $DefaultGroup\WebMenu. Then it is no longer necessary to create a Menu for each group. --Bernhard Weichel

There should be a way to access Group and Title of the current wikipage (not the WebMenu. $WikiGroup?, $WikiTitle?. [[$Title]9 always gives WebMenu. I would like to generate a link to e.g.
[[$WikiGroup]].[[$WikiTitle]]_discuss

Applications are:

  • Menu item to edit the current page
  • Menu item to print the current page
  • Menu item to edit auxillary pages (such as a discussion page, a translation page)


--Bernhard Weichel, August 13, 2003

Did you try using the ThisPage: and ThisGroup: markup for this? You could put [[ThisPage:?action=edit Edit]] in the WebMenu and it refers to the currently browsed page, not the WebMenu itself. --Pm

This works as long as it is in links. So for example

   !Tools
   [[<<]] [[ThisPage:-discuss discuss]]
   [[<<]] [[ThisPage:?action=edit  edit]]
   [[<<]] [[ThisPage:?action=print print]]

works fine. Still I could not find a way to incorporate the current group and pagename (not the MenuPage) into the menu page itself. IMHO a minor problem.
--Bernhard Weichel, August 16,2003

Printable versions

I've changed my local version of webmenu.php to avoid showing the menu when I select "Printable Version" (via PrintablePage), adding at line 13:

if( $action != 'print' ) {

...and of course closing the if at line 34. The condition should take some global configuration variable in account, I think (e.g., $WebMenuShouldPrint). --Development/PedroRabinovitch, August 16, 2003

Once installed, the menu is working, but I am getting the following errors in the header...

Cannot add header information - headers already sent by (output started at /path/to/webmenu.php:37) in /path/to/pmwiki.php on line 350

make sure there are NO trailing spaces after the closing ?> in local.php

At the suggestion of Carlo Strozzi, I made a minor change that will fix the appearance of pages that do not have a webmenu. --Jason Perking 06 Sep 03

See Also

FlexLayout

possible Bug

WebMenu Problems with concatenation $WikiLibDirs = array("wiki.d","wikibak.d","wikilib.d"); WebMenu is not found in wikibak.d
Patrick Ogay 23-Dec-2003

Contributors

  • Jason Perkins
  • Bernhard Weichel
  • Tristan Greaves

pmwiki-2.3.38 -- Last modified by {{}}?

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