diff --git a/data/System/VarTOPICRECURSE.txt b/data/System/VarTOPICRECURSE.txt index a69444f..fecf28c 100644 --- a/data/System/VarTOPICRECURSE.txt +++ b/data/System/VarTOPICRECURSE.txt @@ -14,10 +14,10 @@ | =header="..."= %BR% \ =footer="..."= | Custom format results: see [[FormattedSearch]] for usage & examples | =*Search: '$rootquery'*$n= %BR% =*Total: $ntopics*= | | =format="..."= %BR% \ - | =branchheader="..."= %BR% \ - =branchfooter="..."= | Custom format results: see [[FormattedSearch]] for usage & examples | | =formatbranch="..."= %BR% \ =formatleaf="..."= | Custom format results: see [[FormattedSearch]] for usage & examples; "branch" format is for nodes which have descendents; "leaf" format is for terminating nodes for which there are no others below. | =$indent* [[$web.$topic][$topic]]= | + | =branchheader="..."= %BR% \ + =branchfooter="..."= | Custom format results: see [[FormattedSearch]] for usage & examples | | | =separator="..."= | Separator _between_ search hits. See [[#FormatTokens]] | =$n= | | =nodelimit= | Maximum number of nodes to be displayed. 0 = no limit. | =50= | | =depthlimit= | Maximum depth to recurse to. 0 = no limit. | =0= | diff --git a/lib/Foswiki/Plugins/TopicRecursePlugin/Core.pm b/lib/Foswiki/Plugins/TopicRecursePlugin/Core.pm index e203971..0a55de6 100644 --- a/lib/Foswiki/Plugins/TopicRecursePlugin/Core.pm +++ b/lib/Foswiki/Plugins/TopicRecursePlugin/Core.pm @@ -96,8 +96,18 @@ sub formatNodes { my $result = renderNode( $node, $spec->{formatbranch} ); if ( not $node->isRoot() ) { - push( @renderednodes, $spec->{branchheader}.$result.$spec->{branchfooter} ); + push( @renderednodes, $result ); } + while ( $node->hasNext() ) { + my $child = $node->next(); + push( @renderednodes, formatNodes( $child, $spec )); + } + if(@renderednodes){ + my $length = $#renderednodes; + $renderednodes[0] = $spec->{branchheader}.$renderednodes[0]; + $renderednodes[1] = $spec->{branchheader}.$renderednodes[1]; + $renderednodes[$length] = $renderednodes[$length].$spec->{branchfooter}.$spec->{branchfooter}; + } } else { @@ -108,11 +118,6 @@ sub formatNodes { push( @renderednodes, $result ); } } - while ( $node->hasNext() ) { - my $child = $node->next(); - push( @renderednodes, formatNodes( $child, $spec ) ); - } - return @renderednodes; }