I want to remove the local-tasks tabs and let them appear in the exact same manner as when you hover over a block in Drupal7 and a neat configuration dropdown menu appears where you can click on plus the defined block gets a dotted border.

I figured that the main css-theming will be done once you assign the proper css classes to the wrappers, ul and li's of the local tasks menu. So I modified theme_menu_local_tasks in the following way:

function guerrillabyt_es_menu_local_tasks(&$variables) {
  $output = '';

  if (!empty($variables['primary'])) {
    $variables['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
    $variables['primary']['#prefix'] .= '<a class="contextual-links-trigger" href="#">Configure</a>';
    $variables['primary']['#prefix'] .= '<div class="contextual-links-wrapper contextual-links-processed">';
    $variables['primary']['#prefix'] .= '<ul class="contextual-links" style="display:none;">';
    $variables['primary']['#suffix'] = '</ul></div>';
    $output .= drupal_render($variables['primary']);
  }
  if (!empty($variables['secondary'])) {
    $variables['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>';
    $variables['secondary']['#prefix'] .= '<a class="contextual-links-trigger" href="#">Configure</a>';
    $variables['secondary']['#prefix'] .= '<div class="contextual-links-wrapper contextual-links-processed">';
    $variables['secondary']['#prefix'] .= '<ul class="contextual-links" style="display:none;">';
    $variables['secondary']['#suffix'] = '</ul></div>';
    $output .= drupal_render($variables['secondary']);
  }

  return $output;
}

This works in the sense that markup changes, but the hover-over dropdown behavior isn't added to the specified content-type region.

It's my first time delving into the code of Drupal, so any help in the right directions would be appreciated.

Comments

mixhael’s picture

Anyone?

mixhael’s picture

Ok, managed to do it myself *happy dance*

For anyone who's interested. The tabs are now a dropdown menu, similar to the 'configure block' contextual dropdown menu and will be shown when hovered over the title (screenshot):

added this to template.php of my theme (change 'mytheme' to your theme-name):

function mytheme_menu_local_tasks(&$variables) {
  $output = '';

  if (!empty($variables['primary'])) {
    $variables['primary']['#prefix'] = '<ul class="contextual-links primary-tabs">';
    $variables['primary']['#suffix'] = '</ul>';
    $output .= drupal_render($variables['primary']);
  }
  if (!empty($variables['secondary'])) {
    $variables['secondary']['#prefix'] = '<ul class="contextual-links secondary-tabs">';
    $variables['secondary']['#suffix'] = '</ul>';
    $output .= drupal_render($variables['secondary']);
  }

  return $output;
}

Then added a custom region--content.tpl.php template to my templates directory (my theme is based on Omega) and replaced:

<h1 class="title" id="page-title"><?php print $title; ?></h1>

with

    <div class="contextual-links-region">
	  <h1 class="title" id="page-title"><?php print $title; ?></h1>
	  <?php if ($tabs): ?><div class="contextual-links-wrapper"><?php print render($tabs); ?></div><?php endif; ?>
	</div>
chalee’s picture

I tried implementing your solution but I'm facing challenges. My theme is based on Adaptive theme. It doesn't have the region--content.tpl.php file that you mentioned. Also after adding the function mytheme_menu_local_tasks(&$variables) replacing 'mytheme' with my actual theme name, the function is not being executed at all even after clearing the cache.

Can you give me pointers on how to do this in my Adaptive based theme?

--
Chalee

mixhael’s picture

Hi Chalee,

I took a quick look at adaptive theme and I think you have to override the node.tpl.php

replace:

      <?php if ($title): ?>
        <h1<?php print $title_attributes; ?>>
          <a href="<?php print $node_url; ?>" rel="bookmark"><?php print $title; ?></a>
        </h1>
      <?php endif; ?>

with

      <?php if ($title): ?>
        <div class="contextual-links-region">
        <h1<?php print $title_attributes; ?>>
          <a href="<?php print $node_url; ?>" rel="bookmark"><?php print $title; ?></a>
        </h1>
        <?php if ($tabs): ?><div class="contextual-links-wrapper"><?php print render($tabs); ?></div><?php endif; ?>
	</div>
      <?php endif; ?>

Let me know if that worked for you

chalee’s picture

Sorry for late response. The code above is NOT working.

--
Chalee

beadysea’s picture

Hi Chalee,

I've had look at the AT theme. As far as I know D7 has changed $tabs and the code for this is found in page.tpl.php for Adaptive Themes. Try changing the code:

<?php if ($primary_local_tasks): ?>
            <div id="tasks" class="clearfix">
              <?php if ($primary_local_tasks): ?>
                <ul class="tabs primary"><?php print render($primary_local_tasks); ?></ul>
              <?php endif; ?>
            </div>
          <?php endif; ?>

...

with

<?php if ($primary_local_tasks): ?>
            <div id="tasks" class="clearfix">
              <?php if ($primary_local_tasks): ?>
                <div class="contextual-links-wrapper"><?php print render($primary_local_tasks); ?></div>
              <?php endif; ?>
            </div>
          <?php endif; ?>

          <div class="content-margin"><div class="content-style">

            <?php if ($secondary_local_tasks): ?>
              <div class="contextual-links-wrapper"><?php print render($secondary_local_tasks); ?></div>
            <?php endif; ?>

I think that gets you part of the way there. Let me know if this works for you.

WorldFallz’s picture

That's really awesome-- thanks for posting back your working solution! I never know what to do with those tabs-- i really don't like them, lol.

funature’s picture

i have the same situation like you, using the AT, but it doesn't appear in full node view mode. any idea?

OnkelTem’s picture

Announcing a Drupal 7 module which converts tabs to contextual links.
Module's name: TabsNoMore
URL: http://drupal.org/sandbox/onkeltem/1730244