In Drupal 7, I'm trying to add a <span>
tag inside the <a>
tag of an item in the Main Menu, but it only works for the 'Navigation' menu which is a block, however, I am trying render it within page.tpl.php
I've been searching this up for a while now and can't seem to get it to work. I was attempting to follow the information from How do I insert a <span> </span> tag inside the <a> </a> tag on my main menu
Here's a snippet from page.tpl.php
<nav id="main-menu" class="navigation span8">
<?php print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'id' => 'main-menu-links',
'class' => array('links', 'clearfix'),
),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>
</nav> <!-- /#main-menu -->
and from template.php
function THEMENAME_menu_link(array $variables) {
$element = $variables['element'];
$sub_menu = '';
//$element['#attributes']['class'][] = 'menu-' . $element['#original_link']['mlid'];
$get_title= $element['#title'];
$element['#title']='<span>' . $get_title .' </span>';
$element['#localized_options'] += array(
'attributes' => array(),
'html' => TRUE,
);
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}