CMS Made Simple Forums
https://forum.cmsmadesimple.org/

collapseable menus
https://forum.cmsmadesimple.org/viewtopic.php?f=4&t=177
Page 1 of 1

Author:  brownrl [ Mon Nov 01, 2004 12:31 pm ]
Post subject:  collapseable menus

Is there away already to have lets say a bulletmenu for the navigation menu.

This menu when click would look exactly the same except the section that was cliked then would have its children displayed?

like this:

\$1:
item 1
item 2
item 3




item 2 is clicked

next page then looks like.

\$1:
item 1
item 2
  sub_item1
  sub_item2
item 3



Thanks in advance..
Rob

Author:  Greg [ Mon Nov 01, 2004 6:59 pm ]
Post subject:  collapseable menus

Like this one ...

Switch Menu

I am using this on one of my websites, works very well and is very minimal amount of code.

Author:  sjg [ Thu Jan 27, 2005 7:12 pm ]
Post subject:  Re: collapseable menus

brownrl \brownrl:
Is there away already to have lets say a bulletmenu for the navigation menu.

This menu when click would look exactly the same except the section that was cliked then would have its children displayed?

like this:

\$1:
item 1
item 2
item 3




item 2 is clicked

next page then looks like.

\$1:
item 1
item 2
  sub_item1
  sub_item2
item 3



Thanks in advance..
Rob


I don't know if you're still looking, but I just uploaded an alpha version of a module to the Wiki that includes functionality like this.

Author:  Greg [ Thu Jan 27, 2005 8:06 pm ]
Post subject:  collapseable menus

I have the switch menu code working but the javascript conflicts with javascript from phplayers if it is installed. So you can have either the switch menu or the phplayers menu working on your site but not both at the same time!!

Author:  thetmz [ Fri Feb 11, 2005 10:09 pm ]
Post subject:  collapseable menus

Greg,
Have u implemented switch menu to work as phplayers works? I mean when u add smth in content management it appears on the switch menu?
if yes, could u paste the code..

thx in advance.

Author:  ntro [ Fri Feb 18, 2005 12:58 pm ]
Post subject:  Patch to bulletmenu

I've patched the bulletmenu plugin to do exactly what you're describing. Apply this patch and then call bulletmenu with "collapse='1'" to see it in action.

If this patch doesn't come through in the forum very well, email me or get me on the IRC channel, I'll upload it somewhere and/or email it to whomever wants to commit it to SVN.


\$1:
Index: plugins/function.bulletmenu.php
===================================================================
--- plugins/function.bulletmenu.php   (revision 101)
+++ plugins/function.bulletmenu.php   (revision 103)
@@ -24,6 +24,8 @@
    # getting menu parameters
    $showadmin = isset($params["showadmin"]) ? $params["showadmin"] : 1 ;
 
+   $collapse = isset($params["collapse"]) ? $params["collapse"] : 0 ;
+
    $allcontent = ContentManager::GetAllContent();
 
    # defining variables
@@ -32,8 +34,20 @@
    $count = 0;
    $in_hr = 0;
 
+
+
    if (count($allcontent))
    {
+
+      if ($collapse) {
+         # find hierarchy
+         foreach ($allcontent as $onecontent) {
+            if ($gCms->variables['page_id'] == $onecontent->Id()) {
+               $myhier = $onecontent->Hierarchy();
+            }
+         }
+      }
+
       $menu .= "<div class="bulletmenu">\n";
 
       foreach ($allcontent as $onecontent)
@@ -51,6 +65,73 @@
             }
          }
 
+
+                  if ($collapse) {
+                     $thishier = $onecontent->Hierarchy();
+                     $mypieces = explode(".", $myhier);
+                     $thispieces = explode(".", $thishier);
+
+                     if (count($mypieces) > $thispieces)   
+                        $l = count($mypieces);
+                     else
+                        $l = count($thispieces);
+
+                     # root-level is excepted
+                     if (count($thispieces) > 1) {
+                        $continue = 1;
+                        $myh = $mypieces[0];
+                        $thish = $thispieces[0];
+                        for($i = 1; $i < $l; $i++) {
+
+                           if ($myh == $thish) {$continue = 0; continue;}
+                           if ($thispieces[$i] != '') $thish .= '.' . $thispieces[$i];
+
+                           if ($myh == $thish) {$continue = 0; continue;}
+                           if ($mypieces[$i] != '') $myh .= '.' . $mypieces[$i];
+
+                        }
+                        if ($continue) continue;
+                        if (count($thispieces) > count($mypieces)+1) continue;
+                        $tt = join('.', array_slice($thispieces,0,count($mypieces)));
+                        if (count($thispieces) > count($mypieces) && $myhier != $tt) continue;
+                     }
+                  }
+
          #Now check to make sure we're not too many levels deep if number_of_levels is set
          if (isset($params['number_of_levels']))
          {
@@ -110,13 +191,16 @@
             }
             else
             {
-               $menu .= "<li><a href="".$onecontent->GetURL().""";
+               $menu .= "<li class="bulletmenudepth" . count(explode(".", $onecontent->Hierarchy())). """;
+               $menu .= "><a href="".$onecontent->GetURL().""";
                if (isset($gCms->variables['page_id']) && $onecontent->Id() == $gCms->variables['page_id'])
                {
                   $menu .= " class="currentpage"";
+               } else {
+                  $menu .= " class="bulletmenudepth".count(explode(".", $onecontent->Hierarchy())) . """;
                }
                $menu .= ">".$onecontent->MenuText()."</a>";
-            }
+         }
             $in_hr = 1;
             $last_level = $depth;
          }
@@ -148,6 +232,7 @@
       <li><em>(optional)</em> <tt>showadmin</tt> - 1/0, whether you want to show or not the admin link.</li>
       <li><em>(optional)</em> <tt>start_element</tt> - the hierarchy of your element (ie : 1.2 or 3.5.1 for example). This parameter sets the root of the menu.</li>
       <li><em>(optional)</em> <tt>number_of_levels</tt> - an integer, the number of levels you want to show in your menu.</li>
+      <li><em>(optional)</em> <tt>collapse</tt> - 1/0, whether you want the menu to collapse all but the current.</li>
    </ul>
    </p>
 

Author:  jptechnical [ Sat Feb 19, 2005 6:45 am ]
Post subject:  collapseable menus

I apologize for my ignorance... but how do I patch what I have with what you have? Is is supposed to be merged with the original? Or does it replace it?

thanks.

Author:  Krol [ Tue Feb 22, 2005 3:35 pm ]
Post subject:  collapseable menus

Hi!

I still can't get how to patch the bulletmenu. Can someone experienced please help on this?

Krol

Author:  Ted [ Tue Feb 22, 2005 3:36 pm ]
Post subject:  collapseable menus

This functionality is also in the bulletmenu version released with 0.9.

Author:  Anonymous [ Tue Feb 22, 2005 5:05 pm ]
Post subject:  collapseable menus

wishy \wishy:
This functionality is also in the bulletmenu version released with 0.9.


This is good!
But can I make Section Headers clickable, too?

Author:  Ted [ Tue Feb 22, 2005 5:41 pm ]
Post subject:  collapseable menus

I didn't think of that... I'll have to come up with a fix somehow. Thanks.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/