Search code examples
drupalnavigationdrupal-7htmldrupal-theming

Adding span in navigation


I am Developing a website in Drupal 7

http://lorrells.seoperspective.com/

Now Problem here is the sidebar menu (on Left) my client wants something like in image below enter image description here

means he wants a small amount of text below the link so I was thinking to add "title" text below in span where I can style it

What I want is

<ul>
    <li class="menu-359 first"><a class="Litigation" title="Our niche Litigation Department punches well above its weight." href="http://lorrells.seoperspective.com/Litigation">Litigation</a><span>Our niche Litigation Department punches well above its weight.</span></li>
</ul>

code in page.tpl.php

 <div class="sidebar_menu"> 
     <?php

        $menu = menu_navigation_links('menu-sidebarmenu');
        print theme('links__menu-sidebarmenu', array('links' => $menu));


    ?>

    </div>

Solution

  • Method 1: Have you had a look at this contrib module? It will expose you a checkbox to enter html in menu titles. But am warning you, html in menu items are risky business. Make sure the permissions are set correctly.

    Method 2: Another way you could achieve the same effect could be creating a block with custom markup. But then if you give permission to edit that to your client, that would probably be a disaster waiting to happen.

    Method 3: If you are comfortable in playing with hooks, hook_menu_link_alter(&$item) could be used to set html attribute to true, and also reformat the title, the way you want it.