Additional Wrapper within Link Tag

yanku - June 20, 2009 - 12:31
Project:Menu block
Version:6.x-2.2
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hello

I need to insert an additional wrapper within the link tag,
to clear an CSS issue related with the sIFR Module.

Like:

  • TEXT
  • Which file and where I need to modify, to insert an wrapper around the Text (within the Link).
    A simple "p" tag would do the job.

    Thanks

    #1

    yanku - June 20, 2009 - 12:34

    Sorry example code gone. Again:
    <li><a><span>TEXT</span></a></li>

    #2

    nicholas.alipaz - November 11, 2009 - 00:37
    Priority:critical» normal

    There is not really a graceful way to do this from what I can tell. I did this:

    Copy <root>/sites/all/modules/menu_block/menu-block-wrapper.tpl.php to your theme
    Copy <root>/sites/all/themes/yourtheme/menu-block-wrapper.tpl.php to <root>/sites/all/themes/yourtheme/menu-block-wrapper-yourmenuname.tpl.php

    Then alter your file <root>/sites/all/themes/yourtheme/menu-block-wrapper-yourmenuname.tpl.php to contain:

    <?php
    // $Id: menu-block-wrapper.tpl.php,v 1.5 2008/12/01 09:56:56 johnalbin Exp $

    /**
    * @file menu-block-wrapper.tpl.php
    * Default theme implementation to wrap menu blocks.
    *
    * Available variables:
    * - $content: The unordered list containing the menu.
    * - $classes: A string containing the CSS classes for the DIV tag. Includes:
    *   menu-name-NAME, parent-mlid-MLID, and menu-level-LEVEL.
    * - $classes_array: An array containing each of the CSS classes.
    *
    * The following variables are provided for contextual information.
    * - $settings: An array of the block's settings. Includes menu_name,
    *   parent_mlid, level, follow, depth, expanded, and sort.
    *
    * @see template_preprocess_menu_block_wrapper()
    * @see theme_menu_block_wrapper()
    */
    ?>

    <div class="<?php print $classes; ?>">
      <?php print preg_replace("/<li(.*?)><a(.*?)>([^<]+)<\/a><\/li>/", "<li$1><a$2><span>$3</span></a></li>", $content); ?>
    </div>

    BTW, this is not critical since it doesn't break normal functionality of the module or cause issues with the module in any way.

    #3

    nicholas.alipaz - November 13, 2009 - 03:02
    Category:support request» feature request

    BTW, this would be a great addition to the module as well.

    Please insert any suffix and/or prefix you would like added to each menu item:
    Prefix:
    ====================
    | <span>            |
    ====================

    Suffix:
    ====================
    | </span>            |
    ====================

    [note: this next section would be radio buttons]

    Specify where to add the suffix/prefix:
    o Around the <li> - o Around the <a> - o Around the text

     
     

    Drupal is a registered trademark of Dries Buytaert.