Capita di dover nascondere o eliminare alcuni Tabs di navigazione che Drupal o qualche suo modulo offrono di default.
Per farlo in modo pulito senza mettere mano al codice possiamo sfruttare phptemplate e inserire in seguente codice nel file template.php del nostro tema (o crearne uno appositamente in caso non sia già disponibile):
<?php
/**
* Override or insert PHPTemplate variables into the templates.
*/
function _phptemplate_variables($hook, $vars) {
if ($hook == 'page') {
themename_removetab('Users', $vars); // sostituisci themename con il nome del tuo tema
themename_removetab('Content', $vars); // sostituisci themename con il nome del tuo tema
return $vars;
}
return array();
}
/**
* Removes a tab
*/
function themename_removetab($label, &$vars) { // sostituisci themename con il nome del tuo tema
$tabs = explode("\n", $vars['tabs']);
$vars['tabs'] = '';
foreach($tabs as $tab) {
if(strpos($tab, '>' . $label . '<') === FALSE) {
$vars['tabs'] .= $tab . "\n";
}
}
}
?>Nota: nel caso in cui il codice venga inserito in un template.php già esistente, non andranno inseriti i tag <?php ?>. Se invece il codice verrà inserito in un template.php creato per l'occasione, andrà tralasciato il solo tag di chiusura ?>.
| September 2010 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | ||
Post new comment