Last active
December 15, 2015 05:59
-
-
Save nucklearproject/5212667 to your computer and use it in GitHub Desktop.
How to theming taxonomy page vocabulary name in drupal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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