0

I've created 3 different view and added them to a tab menu.

now these 3 menu items are sorted alphabetically and the default tab menu is printed as middle item .

I wanted to sort them using menus but tab items doesn't exist there .

How can I reorder tab items created by views module?

3

You can provide a weight while editing the Views tab: Edit tab. Higher weights will be moved to the back of the order. But since you cannot see the weights of the other tabs this can take quite a while to get right.

Better is to have a look at Tab Tamer

Tab Tamer is an administration utility that provides easy re-ordering, hiding, and deactivation of tabs and subtabs. You can also rename tab labels.

  • totally forgot tab tamer .. – rémy Apr 19 '16 at 11:02
1

You can adjust the weight in hook_menu_local_tasks_alter:

/**
* Implements hook_menu_local_tasks_alter()
*
* @param $data
* @param $router_item
* @param $root_path
*/
function HOOK_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  if ($root_path == 'admin/content') {
    // You add #weight here on item level not link level
    $data['tabs'][0]['output'][0]['#weight'] = '1000';
  }
}

For more code you can also look here: Altering menu local task title

  • isn't there any solution without coding? anyway thanks for help – Alireza Tabatabaeian Apr 15 '16 at 22:11
0

I know that this is 2 years ago, but this will help somebody looking for similar problem.

here you can see full code for creating menu tabs with weight. (just put weight in $items array under key)

$items['processing'] = array(
    //'title' => t('Create Menu Tab'),
    'access callback' => TRUE,
    'access arguments' => array('dn_release'),
    'page callback' => 'drupal_get_form',
    'page arguments'  => array('dn_wawi_release_form'),
  );

  $items['processing/order/release'] = array(
    'title' => 'Release orders',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'access arguments' => array('dn_release'),
    'page callback' => 'drupal_get_form',
    'page arguments'  => array('dn_wawi_release_form'),
    'weight' => 1,
  );

  $items['processing/order/labels'] = array(
    'title' => 'Print labels',
    'type' => MENU_LOCAL_TASK,
    'access arguments' => array('dn_wawi'),
    'page callback' => 'drupal_get_form',
    'page arguments'  => array('dn_wawi_generate_tracking_form'),
    'weight' => 2,
  );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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