A navigation bar plugin
Add "Previous, Up To Contents & Next" navigation icons or text to TWiki topics.
Principle
If a topic contains the key %NAVBARINDEX%, it is parsed on save for bullet lines
starting with an existing topic name, between the lines containing the keywords %NAVBARINDEX%
and %NAVBARINDEXEND% (if present, or end of topic), which creates an index to the topics.
(named
.navbarcache
in each web). Example:
%NAVBARINDEX%
* FirstSubTopic optionnally followed by some text
* SecondSubTopic with some other text
Indexed topics then has the tag %NAVBAR% expansed into a navigation bar.
(of the form
Prev Up Next, links to previous topic, index topic and next topic).
This tag should be normally part of the skin template, you do not have to add them to your topics by hand.
It works by maintaining a cache of indexed topics in the web, updated when saving the topics.
It thus needs for the Dec 2001 release a patch to add a plugin hook on save functionality that will
be present in the next stable release (Falll 2002):
TWiki:Codev/PluginHookOnSavePatch
It was inspired by the
NavPlugin , with the following features:
- No need to add special tag in indexed pages: only once in the index
- Faster: NavPlugin could double rendering time of big pages
The %NAVBAR% tag can accept options, of the form:
%NAVBAR{prefix="html code..." suffix="html code..." graphics="on"}%
- If NAVBAR is expansed, it will be prefixed and suffixed by the corresponding arguments, if any
- if graphics is not specified, the navbar is in text form, as Prev Up Next links. If set to on, it will use icons. Text will be striked out and icons will be greyed out When there is no previous or no next topic.
graphics can be either the keyword on
, or a string XXX
that will be used to get the URL of a set of images, by appending -next,gif
, -nexti.gif
, ....
The default, graphics="on"
implies for instance:
Plugins/NavbarPlugin/nav
- another optional argument is size, giving additionnal parameters to the
img
tag for html icons when you use the graphics
parameter, to giveheight and width for faster rendering for instance. Its default value (when using graphics="on"
is:
size="width=16 height=16"
See NavbarPluginExample at
https://koala.ilog.fr/wiki/bin/view/Plugins/NavbarPluginExample
Plugin Installation Instructions
- Download the ZIP file from the Plugin web (see below)
- Unzip
NavbarPlugin.zip
in your twiki installation directory.
- Test if the plugin is correctly installed, by
- If you want to use it, modify your skin templates to include %NAVBAR% where you want
In the standard TWiki skin, you may want to edit
templates/view.tmpl
, to add two lines:
%NAVBAR{prefix="<div align=right>" suffix="</div>"%
one just before the %TEXT% line, one just before the %META{"attachments"}% line
Known Issues/Limitations
- All pages referenced in the index must be in the same web as the index page.
- There is a possible race condition if 2 people save at the same time an index topic in the same Web. Re-saving them should do the trick.
- Moving / Renaming the index or the topics is not handled. If anything goes wrong, just removing the .navbarcache and re-saving every index topic will fix thing.
- Creating an entry for a non-existing topic in the index, then creating the topic will not work (as the file do not exists yet as the time of index save). Just edit/save the index once when all topics are defined to be sure.
Plugin Info
Files
- lib/TWiki/Plugins/NavbarPlugin.pm
- data/Plugins/NavbarPlugin.txt
- data/Plugins/NavbarPluginExample.txt
- data/Plugins/NavbarPluginExampleFirst.txt
- data/Plugins/NavbarPluginExampleMiddle.txt
- data/Plugins/NavbarPluginExampleLast.txt
- pub/Plugins/NavbarPlugin/nav-next.gif
- pub/Plugins/NavbarPlugin/nav-nexti.gif inactive (greyed out) version.
- pub/Plugins/NavbarPlugin/nav-prev.gif
- pub/Plugins/NavbarPlugin/nav-previ.gif inactive (greyed out) version.
- pub/Plugins/NavbarPlugin/nav-up.gif
- pub/Plugins/NavbarPlugin/nav-upi.gif inactive (greyed out) version.
--
ColasNahaboo - 11 Sep 2002