Thomas Stig Jacobsen’s constant why

Programming, Internet security and ballroom dance

About

I'm a boy/man blogging on Computers, Security, Internet, Coding and common thoughts...

So If you read my previous post about the fact that Joomla sucks and why Joomla makes me so frustrated you properly thought I would be nice with some solutions on the problems stated.

So I created some hacks as answers, here goes:

A custom menu-maker operating in only one sub-level because that is what I needed. But if you need infinite sub-level just create a function from the code beneath.

 
$menu = JSite::getMenu();
foreach ($menu->getItems("parent", "0") as $item) {
	echo "
<li><a href="\"/$item-">link\">" . $item->name . "</a>";
	if ($menu->getItems("parent", $item->id)) {
		echo "
<ul>";
		echo "
 
";
		foreach ($menu->getItems("parent", $item->;id) as $subItem) {
			echo "
<li><a href="\"/$item-">link\">" . $subItem->name . "</a></li>
 
";
		}
		echo "
 
";
		echo "</ul>
 
";
	}
	echo "</li>
 
\n";
}

Please note that the menu items and the sub-level items is objects and not arrays of data.

Translate: dansk

Leave a Reply