Page 1 of 1

collapseable menus

Posted: Mon Nov 01, 2004 12:31 pm
by 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:

Code: Select all

item 1
item 2
item 3


item 2 is clicked

next page then looks like.

Code: Select all

item 1
item 2
  sub_item1
  sub_item2
item 3

Thanks in advance..
Rob

collapseable menus

Posted: Mon Nov 01, 2004 6:59 pm
by Greg
Like this one ...

Switch Menu

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

Re: collapseable menus

Posted: Thu Jan 27, 2005 7:12 pm
by sjg
brownrl wrote: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:

Code: Select all

item 1
item 2
item 3


item 2 is clicked

next page then looks like.

Code: Select all

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.

collapseable menus

Posted: Thu Jan 27, 2005 8:06 pm
by Greg
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!!

collapseable menus

Posted: Fri Feb 11, 2005 10:09 pm
by thetmz
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.

Patch to bulletmenu

Posted: Fri Feb 18, 2005 12:58 pm
by ntro
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.

Code: Select all

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>
 

collapseable menus

Posted: Sat Feb 19, 2005 6:45 am
by jptechnical
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.

collapseable menus

Posted: Tue Feb 22, 2005 3:35 pm
by Krol
Hi!

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

Krol

collapseable menus

Posted: Tue Feb 22, 2005 3:36 pm
by Ted
This functionality is also in the bulletmenu version released with 0.9.

collapseable menus

Posted: Tue Feb 22, 2005 5:05 pm
by Anonymous
wishy wrote:This functionality is also in the bulletmenu version released with 0.9.
This is good!
But can I make Section Headers clickable, too?

collapseable menus

Posted: Tue Feb 22, 2005 5:41 pm
by Ted
I didn't think of that... I'll have to come up with a fix somehow. Thanks.