Item1381: Add depth parameter to META

pencil
Priority: Enhancement
Current State: Closed
Released In: 1.0.5
Target Release: patch
Applies To: Engine
Component:
Branches:
Reported By: StefanPalm
Waiting For:
Last Change By: KennethLavrsen
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
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 Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy