BreadCrumbsPlugin

A flexible way to display breadcrumbs navigation

Description

This plugin helps you to locate where you are, and shows you how you can escape from there using breadcrumbs navigation.

Two types of breadcrumb are supported; "location" breadcrumbs, which show you where you are in the site hierarchy, taking into account topic parent relationships, and "path" breadcrumbs, that simply show you where you have been, but without going in circles.

In a way, location breadcrumbs have always been supported using the META{"parent"} variable to display the list of parent topics. Since version the advent of hierarchical, subwebs breadcrumbs support of the standard engine does not allow the display of parent webs as part of of the location breadcrumbs.

Path breadcrumbs show you which topics you visited to reach the current topic. If you revisit a topic you visited earlier, the path is trimmed back to that topic, so it gives you a sort of visual history of where you have been on the site. Path breadcrumbs require that you have session support enabled.

The plugin also gives a great deal of flexibility in deciding which parts of the breadcrumbs should be rendered, and how each individual breadcrumb is displayed.

Configuration

While most settings are given as part of the BREADCRUMBS tag, there are a few settings to improve rendering breadcrumbs.

Enabling Path breadcrumbs

To switch on recording the path breadcrumbs, set the BREADCRUMBSPLUGIN_RECORDTRAIL to on. Otherwise the click path of the user won't be recorded and the type setting to the BREADCRUMBS will result in an undefined behaviour.

Displaying TopicTitles

TopicTitles are a concept introduced by the Foswiki:Extensions/DBCachePlugin. These are stored in a topic in the TOPICTITLE preference variable or in a formfield 'TopicTitle ' of a forms attached to the topic. If a TopicTitle is defined for a topic, it will be displayed in the breadcrumbs instead of the normal WikiWord topic name. For efficiency it is recommended to install the Foswiki:Extensions/DBCachePlugin to determine the TopicTitle.

Syntax

%BREADCRUMBS%, %BREADCRUMBS{"<web>.<topic>" ...}%

Parameters:
  • <web>.<topic>: the location to which breadcrumbs should be generated (type="location" only, ignored if type="path") defaults to the current topic
  • type: "location" (the default) or "path"
  • relation: parent property, defaults to "parent" for the native topic-parent-child relation; this can be a formfield that holds a reference to another topic, or even a list of properties to try one after the other until a valid parent has been found (e.g. "ParentTask, Client, parent" to use the formfields ParentTask or Client pointing to a parent, defaulting to the normal parent otherwise)
  • header: format string prepended to the output result
  • format: format string to render one item on the breadcrumbs path (defaults to '[[$webtopic][$name]]')
  • topicformat: format string for any topic items on the path; for example, parent topics. Defaults to the same as format.
  • newtopicformat: similar to topicformat but being used when the topic on the path doesn't exist
  • newwebformat: similar to newtopicformat but being used when the web on the path doesn't exist
  • footer: format string appended to the output result
  • separator: format string to be put between items (defaults to one space char)
  • include: regular expression that items must match to be part of the path
  • exclude: regular expression that items must not match to be part of the path
  • recurse: (type="location" only) can be one or more of the following values (comma separated) to decide which parts of the breadcrumbs path should be included (defaults to 'on'):
    • on: include all parent webs and all parent topics
    • off: include only the current web and the current topic
    • weboff: don't recurse on webs, include only the current web
    • topicoff: don't recurse on topics
    • webonce: include the next parent web but not the parent web's parent web
    • topiconce: include the next parent topic but not the parent topic's parent topic
    • once: short formf of webonce, topiconce
  • spaceout: space out WikiWords inserting a separator (defaults to 'off')
  • spaceoutsep: separator to be used when spacing out WikiWords
  • maxlength: maximum length of a breadcrumbs before inserting an ellipsis in the middle, 0 meaning disable this feature (defaults to 0)
  • ellipsis: character sequence to be inserted when reducing the maxlength of the breadcrumbs (defaults to ' … ')

Pseudo-variables:
Each of the above format strings (format, header, footer, separator) may contain special variables:
  • $name: the name of the breadcrumb, this is the topic name or the web name having its parent web part being stripped off (that is Bar instead of Sandbox/Foo/Bar)
  • $webtopic: the full web.topic of the breadcrumb (wiki syntax)
  • $web: the web part of the current breadcrumb
  • $topic: the topic part of the current breadcrumb
  • $target: the full web/topic of the breadcrumb (url syntax)
  • $name: name of the breadcrumbs item this is the TopicTitle, spaced out or normal topic name topic
  • $n: replaced with a newline char (\n)
  • $percnt: replaced with a percent char (%)
  • $dollar: replaced with a dollar char ($)
  • $nop: removed from the format string before expanding common variables

Examples

default

%BREADCRUMBS%
System BreadCrumbsPlugin

path

%BREADCRUMBS{type="path"}%

%BREADCRUMBS{
  "Web1/Web2/Web3.Topic"
  format="$name"
  separator=" &#187; "}%
Web1 » Web2 » Web3 » Topic

recurse="off"

%BREADCRUMBS{
  "Web1/Web2/Web3.Topic"
  format="$name"
  separator=" &#187; "
  recurse="off"}%
Web3 » Topic

recurse="once"

%BREADCRUMBS{"Web1/Web2/Web3.Topic"
  format="$name"
  separator=" &#187; "
  recurse="once"}%
Web2 » Web3 » Topic

include

%BREADCRUMBS{"Web1/Web2/Web3.Topic"
  format="$name"
  separator=" &#187; "
  include="Web(1|3).*"}%
Web1 » Web2 » Web3

exclude

%BREADCRUMBS{"Web1/Web2/Web3.Topic"
  format="$name"
  separator=" &#187; "
  exclude="Web2"}%
Web1 » Web2 » Web3 » Topic

Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.

Open configure, and open the "Extensions" section. "Extensions Operation and Maintenance" Tab → "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button. Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will not show up in the search results.

You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)
cd /path/to/foswiki
perl tools/extension_installer <NameOfExtension> install

If you have any problems, or if the extension isn't available in configure, then you can still install manually from the command-line. See https://foswiki.org/Support/ManuallyInstallingExtensions for more help.

Dependencies

NameVersionDescription
Foswiki::Plugins::MultiLingualPlugin>=2.00Optional
Foswiki::Plugins::TopicTitlePlugin>1.00Required for Foswiki < 2.2

Change History

17 Jan 2024: improved pod documentation; fixed core constructor
27 Apr 2022: added relation
15 Aug 2018: added newwebformat
28 May 2018: removed local implementation of TopicTitle and use Foswiki:Extensions/TopicTitlePlugin now
05 Mar 2018: added optional support for Foswiki:Extensions/MultiLingualPlugin; modernized internals
31 Jan 2018: modernized internals
23 Apr 2014: don't use DEBUG constant for local debug messages as it conflicts with Assert.pm
04 Nov 2013: added newtopicformat
24 Feb 2012: check access rights before extracting the TopicTitle
20 Aug 2009: fixed usage of $web
03 Jul 2009: fixed fallback method to get the TopicTitle without DBCachePlugin
29 Jun 2009: use Foswiki DBCachePlugin now
17 Apr 2009: converted to Foswiki
07 Jan 2009: fixed breadcrumbs breadcrumbs title for pattern skin
11 Nov 2008: hide WebHome in location breadcrumbs
15 Sep 2008: switching off current topic in topicoff mode
01 Sep 2008: Oliver Krueger Bugs:Item5972 fixed: minor cosmetics
28 Apr 2008: many new features for 2.0: topic titles, ellipsis, …
08 May 2007: respect HOMETOPIC setting, don't hardcoded 'WebHome'
19 Apr 2007: Crawford Currie added topicformat
20 Feb 2007: Crawford Currie added path breadcrumbs
18 Dec 2006: added $webtopic pseudo-parameter
31 Aug 2006: added NO_PREFS_IN_TOPIC; removed commonTagsHandler thus dropping cairo support
08 Aug 2006: fixed topic parents not showing up; don't show non-existing topics
29 Jul 2006: fixed infinit loop when a topic is its own parent topic
28 Jul 2006: initial version; don't add the topic parent 'WebHome' to the path

PackageForm edit

Author Michael Daum
Version 4.01
Release 21 Jan 2024
Description A flexible way to display breadcrumbs navigation
Repository https://github.com/foswiki/BreadCrumbsPlugin
Copyright 2006-2024, Michael Daum
License GPL (GNU General Public License)
Home Foswiki:Extensions/BreadCrumbsPlugin
Support Foswiki:Support/BreadCrumbsPlugin
Topic revision: r1 - 01 Feb 2018, ProjectContributor
This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Irish Doughnut Economics Network? Send feedback