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

    Comments

    stefan81’s picture

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

    nicholas.alipaz’s picture

    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.

    nicholas.alipaz’s picture

    Category: support » feature

    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
    chrisjlee’s picture

    Is there currently a better way of doing this ?
    I'm in need of doing this as well.

    chrisjlee’s picture

    Version: 6.x-2.2 » 7.x-3.x-dev
    JohnAlbin’s picture

    Version: 7.x-3.x-dev » 7.x-2.x-dev
    Status: Active » Fixed

    From the README.txt:

    Theme functions:
    
    Menu block uses Drupal core's menu theme functions. However, it also provides
    theme hook suggestions that can be used to override any of the theme functions
    called by it.
    
    - theme_menu_link() can be overridden by creating one of:
      - [theme]_menu_link__[menu name]()
      - [theme]_menu_link__menu_block()
      - [theme]_menu_link__menu_block__[menu name]()
      - [theme]_menu_link__menu_block__[block id number]()
    
    For example, if you created a bartik_menu_tree__menu_block() function, it would
    override theme_menu_tree() any time it was used by this module, but not when
    used by any other module. Similarly, a bartik_menu_link__menu_block__1()
    function would override theme_menu_link(), but only for the first menu block in
    your system (the menu block with an ID of 1).
    

    Status: Fixed » Closed (fixed)

    Automatically closed -- issue fixed for 2 weeks with no activity.