Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm working on creating some custom user dashboards but cannot seem to find how to remove certain menu items. I intend to use a combination primarily of Panels with Context and Views (but I haven't ruled out simply using Homebox) but at this early stage learning D7 I've created a custom Variant in the system Panels template, created a rule set in the Variant which will set each user dashboard to load based on their subscription (Ubercart Role). Because of the nature of the Roles, different DBs are required. As you can see in the attached screenshot, the menu tabs are showing left to right (View, Affiliate Center, Bookmarks etc), I've tried going through all the backend and cannot for the life of me find what controls them to show, could somebody please tell me what causes them to show, so I can either 'hack it' or delete it.

I know it maybe a theme influence and for my current testing I'm using Bartik, but I intend to use an HTML5 theme based on either AT Theme or Boilerplate, but haven't got to that stage as yet (or that maybe my next 'hack' learning lesson today!). Ultimately, I intend to use a Less framework, but for now I merely want to get the functionality working BEFORE I do CSS.

So, what's influencing the menus in my basic User DB as shown here?

https://dl.dropbox.com/u/55172207/screen_shot_cp.png

Thanks in advance to anyone for the help.

share|improve this question
add comment

2 Answers 2

You can do that from your theme's template.php file by implementing the theme_menu_local_task().

Using this function you can also rename specific tabs.

Code for both actions is below.
It is taken from this file of our Ultima theme.

<?php

/**
 * @file
 * Theme local task function.
 *
 * Created by: Topsitemakers
 * http://www.topsitemakers.com/
 */

/**
 * Implements theme_menu_local_task().
 */
function YOURTHEME_menu_local_task(&$vars) {

  $link = $vars['element']['#link'];

  // List of tab names to be excluded; t() function will ensure that the
  // tab name will be matched and excluded on multilingual sites as well.
  // This is useful in case you have many modules installed on the site and
  // large number of tabs break the layout of the theme.
  $excluded_links = array(
    t('View'),
  );
  if (in_array($link['title'], $excluded_links)) {
    // Skip all further processing.
    return;
  }

  // Uncomment code below to rename the "View" tab for certain node types
  /*
  // Check if the link title is "View"
  if ($link['title'] == t('View')) {
    // Make sure we are on single node page
    if (arg(0) == 'node' && arg(1)) {
      $node = node_load(arg(1));
      // Do this for specific content types
      if ($node->type == 'page') {
        $link['title'] = t('View full page');
      }
    }
  }
  */

  // Continue building the local task link
  $link_text = $link['title'];

  if (!empty($vars['element']['#active'])) {
    // Add text to indicate active tab for non-visual users.
    $active = '<span class="element-invisible">' . t('(active tab)') . '</span>';

    // If the link does not contain HTML already, check_plain() it now.
    // After we set 'html'=TRUE the link will not be sanitized by l().
    if (empty($link['localized_options']['html'])) {
      $link['title'] = check_plain($link['title']);
    }
    $link['localized_options']['html'] = TRUE;
    $link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active));
  }

  return '<li' . (!empty($vars['element']['#active']) ? ' class="active"' : '') . '>' . l($link_text, $link['href'], $link['localized_options']) . "</li>\n";

}
share|improve this answer
    
Thanks Topsitemakers! I'll check that out and feedback later today. –  Paul B Dec 5 '12 at 15:01
add comment
up vote 0 down vote accepted

I solved this by removing the $vars ['tabs'] by commented out // in my template.php file (as seen below). This appears to solve my problem of Tabs appearing. I'm not sure it's correct, but it seems to have solved my issue. FYI, I was using a Bootstrap theme.

// Provide additional variables to theme. $vars['brand'] = theme('brand', array( 'name' => $vars['site_name'], 'href' => $vars['front_page'], 'logo' => $vars['logo'], )); $vars['preface'] = theme('preface', array( 'breadcrumb' => $vars['breadcrumb'], 'title_prefix' => $vars['title_prefix'], 'title' => $vars['title'], 'title_suffix' => $vars['title_suffix'], 'messages' => $vars['messages'], 'help' => $page['help'], 'actions' => $vars['action_links'], ));

// remove Tabs from var above // 'tabs' => $vars['tabs'],

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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