4

In my Drupal 7 template, this one line of code spits out all my menues:

<?php print render($page['header']); ?>

I want to remove extraneous wrapper tags from my menus; for example, Drupal 7 prints out one of my menus as:

<div id="block-menu-menu-top-menu" class="block block-menu">
    <h2>Top menu</h2>
    <div class="content">
        <ul class="menu">
            <li class="first leaf"><a href="/home" title="">Membership</a></li>
            <li class="leaf"><a href="/home" title="">Calendar</a></li>
            <li class="leaf"><a href="/home" title="">Newsletter</a></li>
            <li class="last leaf"><a href="/home" title="">Contact Us</a></li>
        </ul>
    </div>
</div>

I want to simplify it to something like:

<ul class="menu">
        <li class="first leaf"><a href="/home" title="">Membership</a></li>
        <li class="leaf"><a href="/home" title="">Calendar</a></li>
        <li class="leaf"><a href="/home" title="">Newsletter</a></li>
        <li class="last leaf"><a href="/home" title="">Contact Us</a></li>
</ul>

How do I remove unnecessary wrapper tags?

5

I'm not sure if there are template hints that work exactly with this, but you can place block.tpl.php and region.tpl.php (in modules/block/ and modules/system/ respectively) in the theme directory, and then use conditions to sort through which areas you want to be marked up the default way and regions you don't want to be marked up that much.

  • 1
    ah got it....i made a block--menu.tpl.php with the content <?php print $content; ?>. That overwrote the /modules/block/block.tpl.php which contained all the extraneous div wraps. – John Jul 27 '11 at 21:09
  • John, @mrlostman.. I need to implement the same thing.. and I am a newbie to drupal.. but this doesn't worked for me.. Please help me.. – Harish Chinju May 15 '14 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.