You are here: Foswiki>Tasks Web>Item11192 (17 Jan 2024, MichaelDaum)Edit Attach

Item11192: BreadCrumbsPlugin Feature Request: recurse="topicparents"

pencil
Priority: Normal
Current State: Needs Developer
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: BreadCrumbsPlugin
Branches:
Reported By: FlorianSchlichting
Waiting For: MichaelDaum
Last Change By: MichaelDaum
I'd like to request an additional feature for the BreadCrumbsPlugin. What I need is a robust way to include all parent topics and webs, but leave out the current topic, in order to format it differently (different CSS class, no link to itself).

It is easy to set up a template so that the name of the current topic in custom formatting is appended to the plugin output. In order to exclude the topic name from the plugin output (i.e., prevent it from appearing twice), we used to set exclude="%TOPIC%". However, exclude is interpreted as a regex, and with a topic name like AAA+BBB this work-around fails and the topic name appears twice in the bread crumbs.

To properly exclude the current topic, I suggest a new value for the BreadCrumbsPlugin recurse option, named something like "include only parents" / onlyparents or topicparents. Here's the patch:

--- lib/Foswiki/Plugins/BreadCrumbsPlugin/Core.pm.ORG 2011-10-11 16:10:13.230801392 +0200
+++ lib/Foswiki/Plugins/BreadCrumbsPlugin/Core.pm     2011-10-11 17:33:10.186551389 +0200
@@ -265,7 +267,7 @@
   }

   # add this topic if it was not covered yet
-  unless ($seen{"$thisWeb.$thisTopic"} || $recurse->{topicoff} || $thisTopic eq $homeTopic) {
+  unless ($seen{"$thisWeb.$thisTopic"} || $recurse->{topicoff} || $recurse->{topicparents} || $thisTopic eq
+$homeTopic) {
     #writeDebug("finally adding breadcrumb: target=$thisWeb/$thisTopic, name=$thisTopic");
     push @breadCrumbs, {
         target=>"$thisWeb/$thisTopic",
--- data/System/BreadCrumbsPlugin.txt.ORG   2011-10-11 17:39:31.278051253 +0200
+++ data/System/BreadCrumbsPlugin.txt       2011-10-11 17:42:20.334551561 +0200
@@ -71,6 +71,7 @@
       * =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=
+      * =topicparents=: include only parent topics, not the current topic
    * =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,

-- FlorianSchlichting - 21 Oct 2011

 
Topic revision: r3 - 17 Jan 2024, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy