wiki:MenusPlugin

Hierarchical navigation menus

Description

With release of Trac 0.11, existing items can be customized on the main and meta navigation bars. This plugin extends that functionality to:

  • Add items to navigation menus.
  • Hierachical organization, for example using Superfish.

See it in action: http://code.optaros.com/trac/oforge/

Note: CSS modifications might be needed to fit your Trac theme.

See also: NavAddPlugin, TracTabPlugin.

Bugs/Feature Requests

Existing bugs and feature requests for MenusPlugin are here.

If you have any issues, create a new ticket.

defect

14 / 26

enhancement

2 / 8

task

1 / 3

Download

Download the zipped source from here.

Source

Check out MenusPlugin from here using Subversion, or browse the source with Trac.

Installation

To install this plugin, follow these steps:

  1. Install the plugin following the steps in the Trac Documentation.
  2. Add tracmenus.* = enabled to the [components] section of trac.ini or enable via WebAdmin.
  3. Restart the Trac server.
  4. Configure as needed, see below.

Configuration

As usual, configuration takes place in the trac.ini file. Most interesting things first - they are to be found in the [mainnav] section: Here you set up your menu items. Syntax is: <item_name>.<property> = <value> - where <item_name> is either the already existing handler (e.g. "wiki" for the wiki item, "tickets" for the tickets, "newticket" for the "New Ticket" item and so on) - or a term which must not exist for a new item to be introduced (as the "Team Tools" in the Examples section). A special case is top to make a new item appearing on the top level.

Defining menus in the [mainnav] and [metanav] sections

The available properties and their possible values are:

PropertyDescriptionExample value
enabledMust be set to 1 for self defined items to be shown. Can be set to 0 to (temporarily) disable an item.1
hide_if_no_childrenDon't display this (sub) menu if it has no children (e.g. the current user lacks the privileges for all sub-items)1
hrefWhere the item should link to/report/1
labelWhat should be written on the "button"Team Tools
orderMove an item to the left/right. By default, all items have an order of 999 (who will ever reach 999 items must have done something wrong, really!). Use values from 1..999 to define positions. Use a negative value for an item you want to make sure it always comes first - and a value larger than 999 if it sould always come last.5
parentMake the item a sub-item to the one mentioned as valuetop
path_infoString to be matched with the request path info to decide whether a menu item should be displayed. Useful for context dependent items (e.g. in the ctxnav)/wiki
permFor items like reports, hide_if_disabled does not work, since this is no component. Though, it should not be displayed if it is not available. So you can handle this by defining the required permission.REPORT_VIEW
  • inherit: Useful when a menu should receive items from another menu:
    # dummy example - add mainnav items to context menu.
    [ctxtnav]
    inherit= mainnav
    

Defining behaviour in the [menu-custom] section

Although the defaults are fine, you can customize the behavior of MenusPlugin. The syntax for the options is similar to a key-value pair: <option> = <value>. Available options are:

OptionDescriptionDefault
managed_menusWhich menus should be maintained by the plugin.mainnav,metanav
serve_ui_filesWhether the required UI files, ie *.js and *.css files, should be linked into the page. Boolean value.1

The serve_ui_files option you will only need to override if you want to apply your own styles and need to suppress the original ones for this.

Example

The configuration from the demo:

[mainnav]
tags = disabled
search = disabled
timeline = disabled

home = enabled
home.href = /
home.label = Home
home.parent = top
home.order = 10

wiki.label = Wiki
wiki.order = 20

wiki_newpage = enabled
wiki_newpage.href = /newwikipage
wiki_newpage.parent = wiki
wiki_newpage.label = New Wiki Page
wiki_newpage.order = 1

wiki_titleindex = enabled
wiki_titleindex.href = /wiki/TitleIndex
wiki_titleindex.label = Wiki Index
wiki_titleindex.parent = wiki
wiki_titleindex.order = 2

wiki_timeline = enabled
wiki_timeline.href = /timeline?wiki=on
wiki_timeline.label = Recent Changes
wiki_timeline.parent = wiki
wiki_timeline.order = 3

ticketgrp = enabled
ticketgrp.href = /report
ticketgrp.label = Tickets
ticketgrp.order = 30
ticketgrp.parent = top

tickets.parent = ticketgrp
tickets.order = 1
tickets.label = View Reports

query = enabled
query.href = /query
query.label = Custom Query
query.parent = ticketgrp
query.order = 2

newticket.parent = ticketgrp
newticket.order = 3

ticket_defect = enabled
ticket_defect.href = /newticket?type=defect
ticket_defect.parent = newticket
ticket_defect.label = New Defect
ticket_defect.order = 1

ticket_enhancement = enabled
ticket_enhancement.href = /newticket?type=enhancement
ticket_enhancement.parent = newticket
ticket_enhancement.label = New Enhancement
ticket_enhancement.order = 2

ticket_task = enabled
ticket_task.href = /newticket?type=task
ticket_task.parent = newticket
ticket_task.label = New Task
ticket_task.order = 3

ticket_timeline = enabled
ticket_timeline.href = /timeline?ticket=on
ticket_timeline.label = Recent Changes
ticket_timeline.parent = ticketgrp
ticket_timeline.order = 4

browsergrp = enabled
browsergrp.parent = top
browsergrp.href = /browser
browsergrp.label = Code
browsergrp.order = 40

browser.label = Browse Repository
browser.parent = browsergrp
browser.order = 10

browser_log = enabled
browser_log.label = Revision Log
browser_log.href = /log
browser_log.parent = browsergrp
browser_log.order = 20

browser_timeline = enabled
browser_timeline.label = Recent Changes
browser_timeline.href = /timeline?changeset=on
browser_timeline.parent = browsergrp
browser_timeline.order = 30

status.order = 50

tools = enabled
tools.href = #
tools.label = Team Tools
tools.order = 60
tools.parent = top
tools.hide_if_no_children = true

# tools
alfresco.parent = tools
continuum.parent = tools
irclogs.parent = tools
mailarchives.parent = tools
pastebin.parent = tools
roadmap.parent = status

Screenshots

The menu item Tickets on the Navigation bar has been extended with dropdown functionality:

Recent Changes

12147 by rjollos on 2012-10-11 02:42:02
Refs #10133: Added else case so that logic is the same as before [12145].
12146 by rjollos on 2012-10-11 02:31:51
Refs #10133: Removed unnecessary continue statements.
12145 by rjollos on 2012-10-11 02:26:10
Fixes #10133: Don't show entries in the navigation bar if a label with a link element is not defined.
(more)

Author/Contributors

Author: cbalan
Maintainer: Catalin BALAN
Contributors: izzy, rjollos

Last modified 4 months ago Last modified on Feb 3, 2016, 6:46:06 PM

Attachments (1)

Download all attachments as: .zip