Come nascondere i Tabs inutilizzati

tags: Drupal  
drupal tags: search   tabs  

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 ?>.


Similar:

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <h4> <img> <hr>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
Are you human (question to prevent spam)?
Twitter
Add to Technorati Favorites

Featured:

Archives

March 2010
SunMonTueWedThuFriSat
123456
78910111213
14151617181920
21222324252627
28293031
PureDivs Drupal Themes Conversions