Skip to content

Instantly share code, notes, and snippets.

@nucklearproject
Last active December 15, 2015 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nucklearproject/5212667 to your computer and use it in GitHub Desktop.
Save nucklearproject/5212667 to your computer and use it in GitHub Desktop.
How to theming taxonomy page vocabulary name in drupal.
<?php
function THEMENAME_preprocess_page(&$variables, $hook) {
// Theming page--NODETYPE.tpl.php
if (isset($variables['node'])) {
$variables['theme_hook_suggestions'][] = 'page__' . $variables['node'] -> type;
}
/*Template sugestion for vocabulary NAME (String)*/
/*Ex: page--vocabulary--VOCABULARYNAME.tpl.php*/
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
$tid = arg(2);
$query = db_select('taxonomy_vocabulary', 'tv');
$query -> join('taxonomy_term_data', 'ttd', 'tv.vid = ttd.vid and ttd.tid=:tid', array(':tid' => $tid));
$query -> fields('tv', array('machine_name'));
$vname = $query -> execute() -> fetchField();
$variables['theme_hook_suggestions'][] = 'page__vocabulary_' . $vname;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment