In "themes -> [theme folder] -> page.tpl.php", we have these two lines:
<?php if ($title): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif; ?>
<?php if ($tabs): print '<ul class="tabs primary">'. $tabs . '</ul></div>'; endif; ?>
The first line is for the title. The second line is for the tabs "View" and "Edit". So we change the second line to be:
<?php if ($tabs): print '<ul class="tabs primary">'. $tabs . print_custom_tab($node) . '</ul></div>'; endif; ?>
And define the print_custom_tab() function at the end of the page:
<?php
function print_custom_tab($node) {
// Use this to limit the "New" tab to certain page types.
//if (substr($node->type, 0) == "[page type name]")
{
return "<li><a href='?q=node/add/" . str_replace("_", "-", $node->type) . "'>New</a></li>";
}
}
?>
From the $node we can also get $node->uid and other variables associated with node, and can do many other things this way.
Alternatively or in a cleaner way, there is an Add another module that do this. It needs to be configured on what page type and when to show. The configuration is done in "Administer -> Site configuration -> Add another".
No comments:
Post a Comment