Custom Panel pages shown as Tabs
Quick discovery I made last night.. might save some hair pulling:
In the past I have added tabs using panels (or views) to std node tabs or user tabs… I simply would set their path's to something like node/%node/tab1 or user/$user/tab1
I figured I could do this with completely custom pages as well as long as paths were simliar:
custom/tab1, custom/tab2, etc
It seemed like it should work but it wasn't.
Turns out it sort of was working but there is template.php code required to "enable" tabs for non node/user custom panel pages:
<?php
/**
* Implements theme_menu_item_link()
*/
function iguida2_menu_item_link($link) {
if (empty($link['localized_options'])) {
$link['localized_options'] = array();
}
// If an item is a LOCAL TASK, render it as a tab
if ($link['type'] && MENU_IS_LOCAL_TASK) {
$link['localized_options']['attributes']['class'] = pathauto_cleanstring($link['title']);
$link['title'] = '<span class="tab">' . check_plain($link['title']) . '</span>';
$link['localized_options']['html'] = TRUE;
}
return l($link['title'], $link['href'], $link['localized_options']);
}
/**
* Override of theme_menu_local_tasks().
* Add argument to allow primary/secondary local tasks to be printed
* separately. Use theme_links() markup to consolidate.
*/
function iguida2_menu_local_tasks($type = '') {
if (module_exists('ctools')) {
ctools_include('menu');
if ($primary = ctools_menu_primary_local_tasks()) {
$primary = "<ul class='links primary-tabs'>{$primary}</ul>";
}
if ($secondary = ctools_menu_secondary_local_tasks()) {
$secondary = "<ul class='links secondary-tabs'>$secondary</ul>";
}
}
else
{
if ($primary = menu_primary_local_tasks()) {
$primary = "<ul class='links primary-tabs'>{$primary}</ul>";
}
if ($secondary = menu_secondary_local_tasks()) {
$secondary = "<ul class='links secondary-tabs'>$secondary</ul>";
}
}
switch ($type) {
case 'primary':
return $primary;
case 'secondary':
return $secondary;
default:
return $primary . $secondary;
}
}
?>
Add Comment