Changes between Version 5 and Version 6 of TracNavigation


Ignore:
Timestamp:
04/19/23 14:06:21 (20 months ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracNavigation

    v5 v6  
    1 = Trac Navigation =
     1= Trac Navigation
    22
    3 The main and meta navigation entries can be customized in some basic ways. The `[mainnav]` and `[metanav]` configuration sections can be used to customize the text and link used for the navigation items, or even to disable them.  The `mainnav` and `metanav` options in the `[trac]` configuration section can be used to change the order.
     3The main and meta navigation entries can be customized in several ways. The `[mainnav]` and `[metanav]` configuration sections can be used to customize the navigation item text and link, change the ordering of the navigation items, disable them and add new ones.
     4
     5The primary attributes that can be customized are `href`, `label`, `order` and `permission`.
    46
    57=== `[mainnav]` #mainnav-bar
     
    79
    810
    9 ** [=#Example Example] ** 
     11** [=#Example Example] **
    1012
    11 In the following example, we rename the link to the Wiki start "Home", and make the "View Tickets" entry link to a specific report.  The second example (below) also hides the "!Help/Guide" link.
    12 
    13 Relevant excerpt from the TracIni:
    14 {{{
     13In the following example we rename the link to WikiStart //Home//, and make the //View Tickets// entry link to a specific report.
     14{{{#!ini
    1515[mainnav]
    1616wiki.label = Home
     
    1818}}}
    1919
     20Note the entries on the main navigation are displayed in uppercase regardless of the casing of the `label`, unless this aspect of the styling is overridden through [TracInterfaceCustomization#SiteAppearance interface customization].
     21
    2022=== `[metanav]` #metanav-bar
    21 `[metanav]` corresponds to the '''meta navigation bar''', by default positioned above the main navigation bar and below the ''Search'' box. It contains the ''Log in'', ''Logout'', ''!Help/Guide'' etc. entries. This navigation bar is meant to access some global information about the Trac project and the current user.
     23`[metanav]` corresponds to the '''meta navigation bar''', by default positioned above the main navigation bar and below the ''Search'' box. It contains the ''Login'', ''Logout'', ''!Help/Guide'' etc. entries. This navigation bar is meant to access some global information about the Trac project and the current user.
    2224
    23 There is one special entry in the  `[metanav]` section: `logout.redirect` is the page the user sees after hitting the logout button.
     25There is one special entry in the `[metanav]` section: `logout.redirect` is the page the user sees after hitting the logout button. The ''!Help/Guide'' link is also hidden in the following example.
    2426[[comment(see also #Trac3808)]]
    2527
    26 ** Example ** 
     28** Example **
    2729
    28 {{{
     30{{{#!ini
    2931[metanav]
    3032help = disabled
     
    3234}}}
    3335
     36=== Extra Navigation Entries #nav-extra-entries
    3437
    35 === Notes
    36 Possible URL formats (for `.href` or `.redirect`):
     38New navigation entries can be arbitrarily defined and added
     39to the navigation. A new entry can be defined by providing a name with value `enabled`. At a minimum, the `href` attribute should be specified to define a useful navigation entry. If the `label` attribute is not defined the entry's name will be used for the label.
     40
     41The following example creates two new navigation items, one named //My Reports// and the other named //builds//. //My Reports// is only visible to users with `REPORT_VIEW` permission.
     42{{{#!ini
     43[mainnav]
     44myreports = enabled
     45myreports.href = /report/9
     46myreports.label = My Reports
     47myreports.permission = REPORT_VIEW
     48
     49[metanav]
     50builds = enabled
     51builds.href = https://travis-ci.org/edgewall/trac
     52}}}
     53
     54The entry names are always read as lowercase, as is the case for all keys in the trac.ini file due to the way the configuration parser is configured. If the example above used `BUILDS` rather than `builds` for the name, the entry would still be displayed as `builds`. Use the `label` attribute for case-sensitive customization of the navigation entry text.
     55
     56=== Relocating Entries #nav-relocating-entries
     57
     58Navigation entries provided by Trac and plugins can be moved from the meta navigation bar to the main navigation bar, and vise-versa. The entry should be defined in the desired category as if it was a new entry. For example, to move the //Admin// entry to the metanav and rename it to //Administration//:
     59{{{#!ini
     60[metanav]
     61admin = enabled
     62admin.label = Administration
     63}}}
     64
     65Attributes of the navigation item that are not overridden by the configuration will be preserved.
     66
     67=== URL Formats
     68Possible URL formats for `.href` or `.redirect`:
    3769|| '''config''' || '''redirect to''' ||
    3870|| `wiki/Logout` || `/projects/env/wiki/Logout` ||
     
    4173
    4274
    43 === `[trac]` #nav-order
    44 The `mainnav` and `metanav` options in the `[trac]` configuration section control the order in which the navigation items are displayed (left to right).  This can be useful with plugins that add navigation items.
     75=== Ordering #nav-order
     76The `order` attribute specifies the order in which the navigation items are displayed. This can be particularly useful for plugins that add navigation items.
    4577
    46 ** Example **
     78Non-negative floating point values may be used for the `order` attribute. The navigation items will be arranged from left to right in increasing order. Navigation items without an `order` attribute are sorted alphabetically by name.
    4779
    48 In the following example, we change the order to prioritise the ticket related items further left.
     80The default values are:
     81{{{#!ini
     82[mainnav]
     83browser.order = 4
     84newticket.order = 6
     85roadmap.order = 3
     86search.order = 7
     87tickets.order = 5
     88timeline.order = 2
     89wiki.order = 1
    4990
    50 Relevant excerpt from the TracIni:
    51 {{{
    52 [trac]
    53 mainnav = wiki,tickets,newticket,timeline,roadmap,browser,search,admin
     91[metanav]
     92about.order = 5
     93help.order = 4
     94login.order = 1
     95logout.order = 2
     96prefs.order = 3
    5497}}}
    5598
    56 The default order and item names can be viewed in the [TracIni#trac-section trac section of TracIni].
     99=== Permissions #nav-permissions
     100The `permission` attribute controls the visibility of the navigation item on the navigation bar. This is mainly useful for new entries in the navigation bar. Note that it does not provide access control to the URL that the navigation item directs to, and cannot override permission checks done by Trac and plugins.
     101
     102For example, the //Roadmap// navigation item will only display for users with `ROADMAP_VIEW`. Adding the attribute `roadmap.permission = MILESTONE_VIEW` will require both `ROADMAP_VIEW` and `MILESTONE_VIEW` for the entry to be visible, but as noted will not provide access control for the `/roadmap` path. TracFineGrainedPermissions should be used for access control to modules provided by Trac and plugins.
    57103
    58104=== Context Navigation #ctxtnav-bar
     
    60106Note that it is still not possible to customize the '''contextual navigation bar''', i.e. the one usually placed below the main navigation bar.
    61107
    62 
    63108----
    64 See also: TracInterfaceCustomization, and the [http://trac-hacks.org/wiki/NavAddPlugin TracHacks:NavAddPlugin] or [http://trac-hacks.org/wiki/MenusPlugin TracHacks:MenusPlugin] (still needed for adding entries)
     109See also: TracInterfaceCustomization