Posted by leuski on May 9, 2010 at 4:25am
I have a question about how to modify the default view of a panel for authorized users. I have a content type: project. I have a view that lists all the projects. I have a panel page that contains that view. Now, if an authenticated user comes to this page, at the top of the page he sees the the title ("Projects") and two default tabs: "View" and "Edit Panel". I want to add another tab "Add Project" to that row that would be linked to the node/add/project page. Is this possible? How do I do that? I'm running drupal-6.16 and panels-6.x-3.3. Thank you for your help.
Comments
That's not really a Panels
That's not really a Panels question, that's a question about the Drupal menu system. The answer is that it's ridiculously hard to manipulate those tabs. :/
Ah! Thank you for pointing me
Ah! Thank you for pointing me in the right direction. So it's a menu. It's the panel that creates that menu, is it not? I guess, from your comment it's not possible to modify the menu from the interface and one has to write some php code and insert it somewhere, right? Will I be better off just creating my own menu? Can I add a menu of my own to a panel? Is there a way to switch off the default tabs then?
On removing the default tabs
I needed to remove the default tabs too and had to plow through the forums to find an answer. I used this to remove the tabs from a content type 'project' among others. Paste this in your template.php file. Just replace theme with your theme and project with whatever your content type is if this is for a specific content type. This works for other tabs as well, just add them to be removed. You can use different logic too if you want to be specific about where tabs get removed.
<?php
function phptemplate_preprocess(&$variables, $hook) {
$nid = str_replace('page-node-','',$variables['template_files'][1]);
$node = node_load($nid);
if($hook == 'page' && $node->type == 'project') {
theme_removetab('Edit', $variables);
theme_removetab('View', $variables);
theme_removetab('Outline', $variables);
}
return $variables;
}
function theme_removetab($label, &$vars) {
$tabs = explode("\n", $vars['tabs']);
$vars['tabs'] = '';
foreach($tabs as $tab) {
if(strpos($tab, '>' . $label . '<') === FALSE) {
$vars['tabs'] .= $tab . "\n";
}
}
}
?>
Perfect!
montesde, after hours of searching and trial and error, this worked perfect for me!
Thanks!
Great! This really helped me
Great! This really helped me out here! I first tried to accomplish trough hook_menu_alter, but that didn't go anywhere. Additionally, I
<?php
function phptemplate_preprocess_page(&$variables, $hook) {
$nid = str_replace('page-node-','',$variables['template_files'][1]);
$node = node_load($nid);
if($node->type == 'project') {
theme_removetab(t('Edit'), $variables);
theme_removetab(t('View'), $variables);
theme_removetab(t('Outline'), $variables);
}
}
?>
It's surely an useful tip.
It's surely an useful tip. Bookmarking...
How can this be done for
How can this be done for Drupal 7?