I want to alter the ordering of the node tabs for a particular content type.
- From this: View, Edit
- To this: Edit, View
I tried with using menu_local_tasks_alter like this:
function wedding_registry_menu_local_tasks_alter(&$data, $router_item, $root_path) {
foreach ($router_item['page_arguments'] as $key => $argument) {
if (is_object($argument) && $router_item['page_arguments'][$key]->type == 'my_wedding_registry') {
dpm($data);
foreach ($data['tabs'][0]['output'] as $key => $link) {
if ($link['#link']['path'] == 'node/%/view') {
dpm($link['#link']['weight']);
$data['tabs'][0]['output'][$key]['#link']['weight'] = 5;
dpm($data['tabs'][0]['output'][$key]['#link']['weight']);
}
elseif ($link['#link']['path'] == 'node/%/edit') {
dpm($link['#link']['weight']);
$data['tabs'][0]['output'][$key]['#link']['weight'] = 4;
dpm($data['tabs'][0]['output'][$key]['#link']['weight']);
}
}
dpm($data);
}
}
}
Devel is showing the $data array correctly modified:
- first with the default weights (View = -100, Edit = -99)
- after with my modified weigths (View = 5, Edit = 4)
but the tabs on the page are still on the same positions even after clearing the cache!