Foswiki on GitHub is open for business! Next release meeting: Monday September 1, 1300Z

Item1381: Add depth parameter to META

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Enhancement Closed Engine    
Please add this patch by OlivierRaginel to the standard foswiki code.

diff --git a/core/lib/Foswiki/Render.pm b/core/lib/Foswiki/Render.pm
index 60fc252..da189ca 100644
--- a/core/lib/Foswiki/Render.pm
+++ b/core/lib/Foswiki/Render.pm
 -101,6 +101,7 @@ Render parent meta-data
 sub renderParent {
     my ( $this, $topicObject, $ah ) = @_;
     my $dontRecurse = $ah->{dontrecurse} || 0;
+    my $depth       = $ah->{depth}       || 0;
     my $noWebHome   = $ah->{nowebhome}   || 0;
     my $prefix      = $ah->{prefix}      || '';
     my $suffix      = $ah->{suffix}      || '';
 -122,8 +123,11 @@ sub renderParent {
     $parent = $parentMeta->{name} if $parentMeta;
 
     my @stack;
+    my $currentDepth = 0;
+    $depth = 1 if $dontRecurse;
 
     while ($parent) {
+        $currentDepth++;
         ( $pWeb, $pTopic ) =
           $this->{session}->normalizeWebTopicName( $pWeb, $parent );
         $parent = $pWeb . '.' . $pTopic;
 -134,8 +138,10 @@ sub renderParent {
         $text = $format;
         $text =~ s/\$web/$pWeb/g;
         $text =~ s/\$topic/$pTopic/g;
-        unshift( @stack, $text );
-        last if $dontRecurse;
+        if( ! $depth or $currentDepth == $depth ) {
+            unshift( @stack, $text );
+        }
+        last if $currentDepth == $depth;
 
         # Compromise; rather than supporting a hack in the store to support
         # rapid access to parent meta (as in TWiki) accept the hit

-- StefanPalm - 27 Mar 2009

The reason I haven't done it so right away are multiple:
  1. Meta has close to no unit test, so it's hard to know what it's supposed to do
  2. According to Stefan, Meta on (tm)wiki had a depth parameter, which no longer exists in Foswiki (that's the main reason for the patch)
  3. As there are no test, and I'm not too familiar with that, I couldn't really assess what it might break

But as Stefan seems to be a happy bunny now, I'll push for including that smile

Not sure how to classify that though... it was in 4.2, so it could be considered as a bug, but it was like that in 1.0.0...

-- OlivierRaginel - 27 Mar 2009

Small correction - using depth in %META% worked for us in (tm)wiki 4.0.4, (tm)wiki 4.2 we never used...

-- StefanPalm - 27 Mar 2009

ItemTemplate edit

Summary Add depth parameter to META
ReportedBy StefanPalm
Codebase
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Engine
Component
Priority Enhancement
CurrentState Closed
WaitingFor
Checkins Foswikirev:3308 Foswikirev:3310 Foswikirev:3311 Foswikirev:3312 Foswikirev:3323 Foswikirev:3324 Foswikirev:3325 Foswikirev:3326
TargetRelease patch
ReleasedIn 1.0.5
Topic revision: r14 - 25 Apr 2009, KennethLavrsen
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License