Feature Proposal: add topic="xyz" parameter to %META{"parent" ... }%

Motivation

We are using the WidgetsSkin - skin and I see no other chance to add breadcrumbs to the header than something like:
%META{"parent" topic="%BASETOPIC%"}%

would be usefull for WebLeftBar as well.

Description and Documentation

add a new "topic" parameter since $topicObject in lib/Foswiki/Render.pm - renderParent referes to the Topic included, not the currently processed TOPIC.

however, "Macros are expanded relative to the topic they are used in, not the topic they are defined in" as stated in System/Macros seems to be wrong.

Examples

%META{"parent" topic="%BASETOPIC%"}%

Impact

%WHATDOESITAFFECT%
edit

Implementation

-- Contributors: ChristianFerbar - 23 May 2012

patchfile, worked for 1.1.5, too

--- lib/Foswiki/Render.pm       2012-04-11 03:23:38.000000000 +0200
+++ ../Foswiki-1.1.3_patched/lib/Foswiki/Render.pm      2012-05-23 22:26:05.941171218 +0200
@@ -143,6 +119,16 @@
     my $suffix      = $ah->{suffix}      || '';
     my $usesep      = $ah->{separator}   || ' > ';
     my $format      = $ah->{format}      || '[[$web.$topic][$topic]]';
+    my $topic       = $ah->{topic}       || 0;
+    my $pWeb;
+    my $pTopic;
+
+    if ( $topic ) {
+        ( $pWeb, $pTopic ) =
+          $this->{session}->normalizeWebTopicName( $topicObject->web, $topic );
+        $topicObject =
+          Foswiki::Meta->load( $this->{session}, $pWeb, $pTopic );
+    }
 
     my ( $web, $topic ) = ( $topicObject->web, $topicObject->topic );
     return '' unless $web && $topic;
@@ -150,8 +136,7 @@
     my %visited;
     $visited{ $web . '.' . $topic } = 1;
 
-    my $pWeb = $web;
-    my $pTopic;
+    $pWeb = $web;
     my $text       = '';
     my $parentMeta = $topicObject->get('TOPICPARENT');
     my $parent;

Discussion

I see a solution, but I don't get what the problem is that you're trying to solve.

-- ArthurClemens - 23 May 2012

yes please - very good point.

The core issue is that WidgetsSkin parts are all topics INCLUDED, and the tmpl portion is very small. so %META elements are rather confused - they don't refer back to the requested topic, but instead render the INCLUDED WidgetsSkin structure topic.

Christian - have you looked at using %QUERY instead? i think META is somewhat redundant, but I'll have to look - which I will do if we implement this.

-- SvenDowideit - 24 May 2012

Consider BreadCrumbsPlugin for proper breadcrumbs support.

-- MichaelDaum - 24 May 2012

Problem: If I include a section in the WidgedsSkin - part or the WebLeftBar %META{"parent"}% will print the breadcrumbs to that topic, for example WebHome > SystemTopics > WebLeftBar.

As far as I can see %QUERY will only return a single value.

%BREADCRUMBS{"%BASETOPIC%"}% does the trick because i can specify a topic thx!

What about a function for sections to set the current topic? Maybe there are other macros where the topic cannot be specified, too?

Add: there is a bug in my patch if the topic is in a different web, if you are interested, I'll fix that

-- ChristianFerbar - 24 May 2012

I've implemented this for all of the %META macro for 1.2.0

-- SvenDowideit - 25 Jun 2012

 
Topic revision: r9 - 27 Feb 2016, JulianLevens
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