I'm trying to edit the output joomla main_menu module so I can make a custom dropdown menu. At the moment it currently outputs html like this:
<ul class="menu">
<li class="active item1" id="current"><a href="#"><span>First Level Item </span</a></li>
<li class="parent item63"><a href="#"><span>First Level Item Parent</span></a>
<ul>
<li class="item60"><a href="#"><span>Second Level Item</span></a></li>
<li class="item69"><a href="#"><span>Second Level Item</span></a></li>
</ul>
</li>
<li class="item64"><a href="#"><span>First Level Item</span></a></li>
<li class="item66"><a href="#"><span>First Level Item</span></a></li>
What I would like to do is remove the span tags for the output.
What I know so far is that if I want to edit the output; in my template folder I make a directory called 'html' and then inside that a new directory called 'mod___mainmenu' and then a make copy the default.php file from the existing mod_mainmenu folder from the modules directory. All the changes to I make to take file will change the output.
The problem that I'm having is that I can't understand what is happening with the code that is written in the default.php file as it use some XML system that I'm unfamilar with and there are no comments.
If anyone has any ideas that would be super helpful!
Here is the code from the default.php file for the menu:
defined('_JEXEC') or die('Restricted access');
if ( ! defined('modMainMenuXMLCallbackDefined') )
{
function modMainMenuXMLCallback(&$node, $args)
{
$user = &JFactory::getUser();
$menu = &JSite::getMenu();
$active = $menu->getActive();
$path = isset($active) ? array_reverse($active->tree) : null;
if (($args['end']) && ($node->attributes('level') >= $args['end']))
{
$children = $node->children();
foreach ($node->children() as $child)
{
if ($child->name() == 'ul') {
$node->removeChild($child);
}
}
}
if ($node->name() == 'ul') {
foreach ($node->children() as $child)
{
if ($child->attributes('access') > $user->get('aid', 0)) {
$node->removeChild($child);
}
}
}
if (($node->name() == 'li') && isset($node->ul)) {
$node->addAttribute('class', 'parent');
}
if (isset($path) && in_array($node->attributes('id'), $path))
{
if ($node->attributes('class')) {
$node->addAttribute('class', $node->attributes('class').' active');
} else {
$node->addAttribute('class', 'active');
}
}
else
{
if (isset($args['children']) && !$args['children'])
{
$children = $node->children();
foreach ($node->children() as $child)
{
if ($child->name() == 'ul') {
$node->removeChild($child);
}
}
}
}
if (($node->name() == 'li') && ($id = $node->attributes('id'))) {
if ($node->attributes('class')) {
$node->addAttribute('class', $node->attributes('class').' item'.$id);
} else {
$node->addAttribute('class', 'item'.$id);
}
}
if (isset($path) && $node->attributes('id') == $path[0]) {
$node->addAttribute('id', 'current');
} else {
$node->removeAttribute('id');
}
$node->removeAttribute('level');
$node->removeAttribute('access');
}
define('modMainMenuXMLCallbackDefined', true);
}
modMainMenuHelper::render($params, 'modMainMenuXMLCallback');