Last updated December 20, 2012. Created by peteruithoven on December 20, 2012.
Log in to edit this page.
When you want to do more advances contextual filtering you could use PHP contextual filter code.
Example:
There is a questions taxonomy with a number of questions.
There is a content type with 2 term reference fields, Raised questions and Answered questions
Under each page I want a list with links to pages that answer questions raised on the page.
- To get this, create a new view with a block display.
- Create a contextual filter, on the Answered questions field.
- Select Provide default value.
- Select at Type; PHP-code.
- Use the following code:
<?php
$node = node_load(arg(1));
if($node && isset($node->field_raised_questions[LANGUAGE_NONE])) {
foreach($node->field_raised_questions[LANGUAGE_NONE] as $term) {
$terms[] = $term['tid'];
}
return implode('+',$terms);
}
else {
return;
}
?>- Under More, select: Filter to items that share any term.
Comments
Thank you, peteruithoven.
Thank you, peteruithoven. This was exactly what I was looking for. I worked like a charm.