You are here: Foswiki>Tasks Web>Item2030 (18 Oct 2012, SvenDowideit)Edit Attach

Item2030: MenuListPlugin does not behave as described in docs

pencil
Priority: Normal
Current State: Confirmed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: MenuListPlugin
Branches: trunk
Reported By: AndrewFindlay
Waiting For: SvenDowideit
Last Change By: SvenDowideit
Several problems with MenuListPlugin:

  1. In "collapse" mode, when displaying a page that is listed in the menu, the plugin only displays the items at the same level and back to the root of that level. It does not display other menu items at level 1 as indicated in the documentation.
  2. Plugin requires the menu definition to include the web name in the links.

Probably related to Item1859: http://foswiki.org/Tasks/Item1859

I have attached a suggested fix for the display problem. The second might be regarded as a documentation error.

Andrew

mmm, thanks - I have to do some more testing to see what happens, i hope its not


diff --git a/lib/Foswiki/Plugins/MenuListPlugin.pm b/lib/Foswiki/Plugins/MenuListPlugin.pm
index 272eb39..93d1290 100644
--- a/lib/Foswiki/Plugins/MenuListPlugin.pm
+++ b/lib/Foswiki/Plugins/MenuListPlugin.pm
@@ -85,6 +85,7 @@ sub MENULIST {
             push( @list, { tabs => $1, length => length($1), string => $2 } );
 
 #        my ($w, $t) = Foswiki::Func::normalizeWebTopicName($baseWeb, $list[$#list]{string});
+           # TODO: handle the case where one topic name in the list is an initial substring of another one
             if (    ( $currentTopicIndex < 0 )
                 and ( $list[$#list]{string} =~ /.*$baseWeb\.$baseTopic.*/ ) )
             {
@@ -127,20 +128,28 @@ sub MENULIST {
             {
             }
 
+           # Output level-1 items up the the root
+           for ( my $idx = 0; $idx < $startIdx; $idx++ ) {
+               if ( $list[$idx]{length} == 1 ) {
+                   push( @out, $idx );
+               }
+           }
+
             #go backwards, then reverse later
             my $lastIdx      = $currentTopicIndex;
             my $currentLevel = $list[$currentTopicIndex]{length};
+           my @stack;
             for ( my $idx = $lastIdx ; $idx > 0 ; $idx-- ) {
                 if ( ( $list[$idx]{length} == 1 ) ) {    #
-                    push( @out, $idx );
+                    push( @stack, $idx );
                     last;
                 }
                 if ( $list[$idx]{length} <= $currentLevel ) {
                     $currentLevel = $list[$idx]{length};
-                    push( @out, $idx );
+                    push( @stack, $idx );
                 }
             }
-            @out = reverse(@out);
+            push( @out, reverse(@stack));
 
             #if the current node has childern, show those
             $lastIdx = $currentTopicIndex + 1;
@@ -164,12 +173,10 @@ sub MENULIST {
                     }
                 }
             }
+
+           # Show the rest of the list, working back to level 1
             $currentLevel = $list[ $lastIdx - 1 ]{length};
             for ( my $idx = $lastIdx ; $idx < $#list ; $idx++ ) {
-                if ( ( $list[$idx]{length} == 1 ) )
-                { # or ($list[$idx]{length} < $list[$currentTopicIndex]{length})) {          #output until we go below the level of the current again.
-                    last;
-                }
                 if ( $list[$idx]{length} <= $currentLevel ) {
                     $currentLevel = $list[$idx]{length};
                     push( @out, $idx );

Sven

ItemTemplate edit

Summary MenuListPlugin does not behave as described in docs
ReportedBy AndrewFindlay
Codebase
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Extension
Component MenuListPlugin
Priority Normal
CurrentState Confirmed
WaitingFor SvenDowideit
Checkins MenuListPlugin:bee0977ad50d
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches trunk
trunkCheckins MenuListPlugin:bee0977ad50d
Release01x01Checkins
I Attachment Action Size Date Who Comment
MenuListPlugin.pmpm MenuListPlugin.pm manage 7 K 10 Sep 2009 - 12:01 AndrewFindlay Fixed version of <nop>MenuListPlugin.pm
Topic revision: r3 - 18 Oct 2012, SvenDowideit
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