我想编辑输出joomla main_menu模块,所以我可以做一个自定义的下拉菜单。目前,它目前输出HTML这样的:Joomla主菜单html输出
<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>
我想要做的是去除跨度标签的输出。
我所知道的,到目前为止是,如果我想要编辑的输出;在我的模板文件夹中,我创建一个名为'html'的目录,然后在一个名为'mod___mainmenu'的新目录中,然后从模块目录的现有mod_mainmenu文件夹中复制default.php文件。我对文件进行的所有更改都会更改输出。
我遇到的问题是我无法理解在default.php文件中编写的代码发生了什么,因为它使用了一些我不喜欢的XML系统,并且没有任何评论。
如果有人有任何想法,将是超级有用!
这里是从菜单中如default.php文件中的代码:
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');
这是几十个我讨厌和拒绝使用的Joomla的原因之一。 – ceejayoz 2008-12-29 20:03:08