I am trying to edit the joomla main_menu output module so that I can create a custom drop-down menu. At the moment, it outputs html as follows:
<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 output.
I know that if I want to edit the output; in my template folder I create a directory called "html" and then inside this new directory with the name "mod___mainmenu" and then make a copy of the default.php file from the existing mod_mainmenu folder from the modules directory. All changes made to the file will change.
The problem I am facing is that I cannot understand what is happening with the code written in the default.php file, because it uses some XML system that I disagree with, and there are no comments.
If anyone has ideas that would be very 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');
source share