Getting a term on a node is usually asked for but i'm after getting a term that set on a term while displaying term page through views. I need this to determine layout, aligning the page title left, right or centered based on the selected term on the term page.
To clarify
Vocabularies
A = collection
B = Layout (with terms left, right or center)
Example
Voc A can have a term from Voc B
When displaying Voc A with views I need the value from Voc B(attached to the term page) as a variable in page.tpl.php or to be set as a body-class
One of several attempts I have made
function THEME_preprocess_page(&$vars) {
$term = menu_get_object('taxonomy_term',2);
if ($term) {
$field_layout_value = field_get_items('taxonomy_term', $term, 'field_layout');
if ($field_layout_value) {
$vars['layout'] = field_view_value('taxonomy_term', $term, 'field_layout', $field_layout_value['und'][0]['value']);
}
}
}
Really hope someone can help out!!
Comments
Add Body class based on taxonomy
Hi,
Add below snippet on template.php
You can use drupal Body Classes module as well.
Thank you for your reply!
Thank you for your reply!
If i'm not mistaken this looks at terms on a node
I have a term referencing a term from another vocabulary that I need to use. I need to see wat terms are on a term not on a node.
Add below code in template
Add below code in template.php, in THEME_preprocess_html(&$variables)
It took me a while to get
It took me a while to get back to this but nonetheless, h3jain thank you very much, exactly what I needed.