Page 1 of 1

Changes to bulletmenu

Posted: Sun Jan 30, 2005 10:04 pm
by Greg
I found the original bulletmenu plugin did not produce proper html code so made the following changes:

Code: Select all

Line 37 - from: $menu .= "<div class=\"bulletmenu\">\n"; to: $menu .= "<div class=\"bulletmenu\">\n<ul>";
Line 82 - from: $menu .= "</ul>\n"; to: $menu .= "\n</ul>\n";
Line 88 - from: $menu .= "<ul>\n";  to: $menu .= "<ul>";
Line 95 - from: for ($i = $depth; $i < $last_level; $i++) $menu .= "\n</li>\n</ul>\n"; to: for ($i = $depth; $i < $last_level; $i++) $menu .= "\n";
Line 98 - from: $menu .= "</li>\n"; to: $menu .= "</ul>\n<ul>\n";
Line 102 -from: for ($i = $depth; $i > $last_level; $i--) $menu .= "\n<ul>\n"; to: for ($i = $depth; $i > $last_level; $i--) $menu .= "\n";
Line 105 -from: $menu .= "</li>\n"; to: $menu .= "\n";
Line 109 -from: $menu .= "<li style=\"list-style-type: none;\"><hr class=\"separator\"/>"; to: $menu .= "<hr class=\"separator\"/>";
Line 118 -from: $menu .= ">".$onecontent->MenuText()."</a>"; to: $menu .= ">".$onecontent->MenuText()."</a></li>";
Line 126 -from: for ($i = 0; $i < $last_level; $i++) $menu .= "</li></ul>"; to: for ($i = 0; $i < $last_level; $i++) $menu .= "\n</ul>";
Line 130 -from: $menu .= "<ul><li><a href='admin/'>Admin</a></li></ul>\n"; to: $menu .= "\n<ul><li><a href='admin/'>Admin</a></li></ul>\n";
I haven't tested it for 'deeper' level menus but it formats a 2 level menu properly with these changes. With properly formatted html, css can be applied and the menu can be used with DHTML menus such as the switch menu.

Changes to bulletmenu

Posted: Thu Feb 03, 2005 8:10 pm
by fredp
Me too tried to make a simpler (and, I hope, better) bulletmenu, in which everything is a and there aren't inside , so it's easier to customize it with css.

Replace the old "if (count($allcontent)) { ... }" with this:

Code: Select all

if (count($allcontent))
	{
		$menu .= "<div class=\"bulletmenu\">\n<ul class=\"lev1\">\n";
		$curdepth = 1;
		
		foreach ($allcontent as $onecontent)
		{
			#Handy little trick to figure out how deep in the tree we are
			#Remember, content comes to use in order of how it should be displayed in the tree already
			$depth = count(split('\.', $onecontent->Hierarchy()));

			if ($depth > $curdepth) {
				$menu .= "\n<ul class=\"lev".$depth."\">\n";
				$curdepth++;
			}
			
			if ($depth < $curdepth) {
				$menu .= "\n</ul>\n";
				$curdepth--;
			}

			$count++;

			if (!$onecontent->Active() || !$onecontent->ShowInMenu())
				continue;
			
			switch ( $onecontent->Type() ) {
			
				case 'sectionheader':
					$class = ' class="sectionheader"';
					$content = $onecontent->MenuText();
					break;
					
				case 'separator':
					$class = ' class="separator"';
					$content = '<hr class="separator" />';
					break;
					
				default:
					$class = '';
					$content = '<a href="'.$onecontent->GetURL().'">'.$onecontent->MenuText().'</a>';
					if (isset($gCms->variables['page_id']) && $onecontent->Id() == $gCms->variables['page_id'])
						$class = ' class="isactive"';
					break;
				
			}
			
			$menu .= "<li$class>$content</li>\n";

		}
		
		$menu .= "</ul>\n";
		
		if ($showadmin == 1)
			$menu .= "<ul id=\"linkadmin\"><li><a href='admin/'>Admin</a></li></ul>\n";
		
		$menu .= "</div>\n";
	}
I haven't tested it much, with my CSS it seems to work. You need a special class li.separator (to remove the bullet for the separator) and li.sectionheader (to customize the section header).

I made it because I found some troubles in the rendering of the structure of my site (perhaps due to previous changes I made) and I wasn't able to fix it, so I wrote a simple function that fits my needs (or needings? :?: ).

Does this work for you? :D

Re: Changes to bulletmenu

Posted: Fri May 27, 2005 10:28 pm
by koehler
Found a bug when you go back 2 levels.
Just replace leveler "if" with "while"

Code: Select all

                      while ($depth > $curdepth) {
				$menu .= "\n<ul class=\"lev".$depth."\">\n";
				$curdepth++;
			}
			
			while ($depth < $curdepth) {
				$menu .= "\n</ul>\n";
				$curdepth--;
			}

Re: Changes to bulletmenu

Posted: Fri Jul 15, 2005 7:29 am
by ljbadenz
I went to use this but i put into a new file that I've attached.

Just use {bulletmenu2}.

Maybe whishy will put this code into the next CMSMS.

[attachment deleted by admin]

Re: Changes to bulletmenu

Posted: Wed Jul 27, 2005 5:10 am
by iNSiPiD
Also, it seems that content types of Link don't get the 'selected' class.