drupaldrupal-7drupal-themingdrupal-menu

Delete div from menu block drupal 7


How can I delete all thoses div around my menu create with menu_block for drupal 7 ?

I want to change this :

<div class="region region-nav">
    <div class="content">
        <div class="menu-block-wrapper menu-block-3 menu-name-menu-prive parent-mlid-0 menu-level-2">
            <ul class="menu">
                <li class="first expanded menu-mlid-559" style="width: 397px;">
                    <a href="/fr/priv%C3%A9s/avantage">Avantages</a>
                    <ul class="menu">
                        <li class="first leaf menu-mlid-596">
                            <a href="/fr/priv%C3%A9s/avantage/eco">Ecologie</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</div>

into this :

<ul class="menu">
    <li>
        <a href="#">link</a>
        <ul class="menu">
            <li>
                <a href="#">link</a>
            </li>
        </ul>
    </li>
</ul>

Thank you


Solution

  • You will need to add new templates for your block and the region that holds it, in order to get rid of some of the markup.

    Take a look at Drupal 7 Template Suggestions

    Your block template name would look like this: block--menu-block.tpl.php. And for the markup, can be just

    <?php print $content ?>
    

    The region template name would look like this `region--YOUR_REGION_NAME.tpl.php``. And for the markup, can be just

    <?php print $content ?>
    

    (Don't forget to flush the caches after adding the new templates)