Drupal 7
I have a vocabulary with hierarchical terms countries and cities.
I have a view with context filter=cityA ( parent country A)
How I can display into a block all cities from country A ( siblings of cityA from vocabulary)?
Thanks
You can try using taxonomy_get_children($termid)
to get children of term and then taxonomy_get_parents($termid)
and again taxonomy_get_children()
to get the siblings .
The following is the code I used in such situation :
<?php
if (isset($page['#views_contextual_links_info']['views_ui']['view']->args[0])){
$termid = $page['#views_contextual_links_info']['views_ui']['view']->args[0];
$terms = taxonomy_get_children($termid);
if (empty($terms)) {
$parent = taxonomy_get_parents($termid);
$terms = taxonomy_get_children(key($parent));
}
}
if (isset($node->field_category['und'][0]['tid'])) {
$termid = $node->field_category['und'][0]['tid'];
$terms = taxonomy_get_children($termid);
}
?>