Back to the extension listing.
Webgen::Tag::Menu
Summary
The following tag names are registered for this tag class: menu
This tag uses the following options:
tag.menu.used_nodes
tag.menu.start_level
tag.menu.min_levels
tag.menu.max_levels
tag.menu.show_current_subtree_only
tag.menu.nested
Description
The menu tag builds a seemingly simple menu using HTML lists. However, it is very flexible due to its many options that let you decide every detail of the menu.
The menu is constructed using HTML lists with
ul
andli
tags. However, the menu normally looks better if no discs are shown for the menu items (using the CSS directivelist-style-type: none
).
It uses the meta information in_menu
and sort_info
to determine which nodes should be in the
menu and how they should be ordered. A separate menu tree is then created from all nodes for each
language.
By setting the option tag.menu.used_nodes
to fragments
, the menu tag can also be used for
generating an in-page content menu of all the header sections.
When using the option value
files
fortag.menu.used_nodes
, all nodes which are only in the menu because they have fragment nodes beneath them are not included in the menu.However, when using the value
all
fortag.menu.used_nodes
, some nodes which havein_menu
set tofalse
may appear in the menu if they have fragments beneath them that are in the menu!
The rendered menu consists of ul
and li
tags and the links (or span
elements) to the menu
entries . The li
tags have special CSS classes set for styling. These CSS class names are as
follows:
webgen-menu-levelNUMBER
: Set on all menu items and can be used to style specific menu levels only.NUMBER
is replaced with the actual menu level, so the first level menu entries will get awebgen-menu-level1
class.webgen-menu-submenu
: Set if the menu item contains sub menu items.webgen-menu-submenu-inhierarchy
: Set if the menu item contains sub menu items and it is in the sub tree of the rendered node.webgen-menu-item-selected
: Set if the menu item corresponds to the rendered node.
The option tag.menu.nested
decides whether a nested menu or a non-nested is generated. When
setting this option to false
you need to ensure that tag.menu.show_current_subtree_only
is set
to true
and tag.menu.min_levels
is set to 1
. Both ensure that no other subtree obfuscates the
menu.
Set
tag.menu.nested
tofalse
if you want to generate, for example, a horizontal menu, ie. a menu that has one horizontal bar for each menu level.
“Static” Menus
It is also possible to define a “static” menu or to augment the dynamic menu with static entries by using virtual files. They can be used to structure the menu the way you like it. This way it is also possible to add one page under two different headings:
features.en.html:
in_menu: true
title: Features
url: index.en.html#features
newdir:
sort_info: 2
newdir/new.en.html:
sort_info: 1
in_menu: true
url: ../features.en.html
There is no need to specify in_menu
for newdir
since a page under the directory is in the
menu. Also be aware that you need to set the language explicitly if a file should only appear in the
menu for a specific language. Otherwise it appears in every menu. The url
specifies the file that
should be shown when clicked on the generated link.
A completely “static” menu can be generated by only using virtual directories and files and not
setting in_menu
for any other node.
Examples
Usage | Output |
---|---|
{menu: } | |
{menu: {used_nodes: all}} | |
{menu: {used_nodes: files}} | |
{menu: {used_nodes: fragments}} | |
{menu: {used_nodes: all, nested: false}} |
Back to the extension listing.