Priority: Normal
Current State: Confirmed
Released In: n/a
Target Release: n/a
Several problems with
MenuListPlugin:
- 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.
- 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