Jump to content

add tag to Joomla php to alter output


nitro29

Recommended Posts

Hi,

 

I am very new to php, so would appreciate any advice with this probably very noob question.

 

I need to moderate - make an alternate - joomla module menu php file which adds a <span> tag to the output. I have added the <span> but it is not in the right position. I can only get it either before or after the anchor tag, not in between as needed.

 

The HTML output for the menu and one menu item is:

 

<ul id="mainNav" class="nav menu ">
<li class="item-435">
<span></span>
<a href="/testserver/joomla/dev">Development</a>
</li>
</ul>

 

I need the <span> tag inside the anchor tag in order for my background hover and link function to work correctly, like this:

 

<ul id="mainNav" class="nav menu ">
<li class="item-435">
<a href="/testserver/joomla/dev">Development<span></span></a>
</li>
</ul>

 

Can anyone help me??

 

 

This is the current php code for the module (which gives the wrong <span> placement):

 

<?php
/**
* @package Joomla.Site
* @subpackage mod_menu
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

// Note. It is important to remove spaces between elements.
?>
<?php // The menu class is deprecated. Use nav instead. ?>
<ul class="nav menu <?php echo $class_sfx;?>"<?php
$tag = '';
if ($params->get('tag_id') != null)
{
$tag = $params->get('tag_id').'';
echo ' id="'.$tag.'"';
}
?>>
<?php
foreach ($list as $i => &$item) :
$class = 'item-'.$item->id;
if ($item->id == $active_id) {
$class .= ' current';
}

if (in_array($item->id, $path)) {
$class .= ' active';
}
elseif ($item->type == 'alias') {
$aliasToId = $item->params->get('aliasoptions');
if (count($path) > 0 && $aliasToId == $path[count($path) - 1]) {
$class .= ' active';
}
elseif (in_array($aliasToId, $path)) {
$class .= ' alias-parent-active';
}
}

if ($item->type == 'separator') {
$class .= ' divider';
}

if ($item->deeper) {
$class .= ' deeper';
}

if ($item->parent) {
$class .= ' parent';
}

if (!empty($class)) {
$class = ' class="'.trim($class) .'"';
}

echo '<li'.$class.'><span></span>';

// Render the menu item.
switch ($item->type) :
case 'separator':
case 'url':
case 'component':
case 'heading':
require JModuleHelper::getLayoutPath('mod_menu', 'default_'.$item->type);
break;
default:
require JModuleHelper::getLayoutPath('mod_menu', 'default_url');
break;
endswitch;

// The next item is deeper.
if ($item->deeper) {
echo '<ul class="nav-child unstyled small">';
}
// The next item is shallower.
elseif ($item->shallower) {
echo '</li>';
echo str_repeat('</ul></li>', $item->level_diff);
}
// The next item is on the same level.
else {
echo '</li>';
}
endforeach;
?></ul>

 

I have tried messing around with the <span> tags but just can't make it work..

 

I would really appreciate any help. Thanks in advance!!!

 

/Soren

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.