Hi,
If anyone is interested in getting the parent term (first term that is found) as contextual filter on a term page (not a node page), you could do the following. Instead of selecting 'Load default filter from node page', select 'Load default filter from term page' in the contextual filter config. This is not working at the moment unless you modify this code:
Replace the first if-statement in get_argument() (views_plugin_argument_default_parent_taxonomy_tid.inc) by:
// Load default argument from taxonomy page.
if (!empty($this->options['term_page'])) {
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
// Get all parents.
$parents = taxonomy_get_parents(arg(2));
// Get first parent.
$single_term = reset($parents);
if (isset($single_term->tid)) {
return $single_term->tid;
} else {
// If no parents, return the original tid.
return arg(2);
}
}
}
I used this to get the parent term of the current term and then again the childs of that parent to display on the current term page, which basically means I display the term's siblings on its page. Perhaps the code could be optimised, but it does the trick for now.
Cheers
Comments
Comment #1
fernly commentedComment #2
alisonIt's very unfortunately that the "from term page" contextual filter doesn't work. Thanks for the workaround!
Comment #3
SchwebDesign commentedwould it be possible for this to be committed?
Comment #4
juliakoelsch commentedThis worked for me also. Thanks!