I'm developing a site in drupal 7 that needs a related content block. The problem is that I tried Similar entries and Similar by terms modules but it looks like they are not compatible with views 7.x-3.0 I'm using, yet.

There is an error message when I install both modules and in the bug reports I found posts with errors just like mine but without good solutions.

I was thinking until the modules are ready, maybe, I can, somehow, use views and show random content based on the taxonomy term in the node and not show the current node.

Is there a way to use contextual filters and use arguments from taxonomy in the current node?

If you know some other way or module to achieve something similar please point me in the right direction.


4 Answers 4


I've achieved this using a view to pull nodes that share the same taxonomy as your current node.

Basically create a view that uses the 'Has taxonomy term' contextual filter. And also include a content NID contextual filter to exclude the current node (in the list appearing in that view).

Follow the example here to create the view ('Views 3' steps at top): http://www.metachunk.com/blog/adding-related-content-view-drupal-7

I've also taken it a bit further and ticked 'Reduce Duplicates' and 'More > Allow multiple values'. That way you can specify multiple terms from your current node and only get a node once if it appears in more than one term.

Make sure you select the fields you'd want to see in your template.

My view is also filtered to one content type 'news' so i've named it 'related_news'. I use the following code in my template.php to grab the views content and pass the template an array. Add your custom fields to the $terms array to then use their ID to find related content.

 * Return result of Related News view for a specific node.
 * TO-DO: Add default functionality.
 * @param object $node
 * @return array 
function [template]_get_related_news($node) {

    $terms = array();

    //Get terms from fields.
    $terms = array_merge($terms, $node->field_field_term_1);
    $terms = array_merge($terms, $node->field_field_term_2);

    //Build array of ids
    $termIDs = array();

    foreach ($terms as $terms){
        $termIDs[] = $terms['raw']['tid'];

    //Load view     
    $relatedView = views_get_view('related_news');

    //Execute view with term ids as argument. Include node id to exlude it from results
    $relatedView->set_arguments(array(implode('+', $termIDs), $node->nid));

    return $relatedView->result;


You could also get the view to produce a block and use this to display the content within your theme.


I think you can do this with panels and views.

create a view listing all the nodes with a taxonomy term in advanced set the context to the term you want to view by create a 'content pane' within that view and set arguments input to that term now create a panel for the original node, attach the view pane to it, and pass the taxonomy to the view pan.

This explanation sounds a little confusing, but here is a great video to help



Have you tried EVA (Entity Views Attachment) ?

You already have existing views. You can extend that view with EVA. EVA will accept a taxonomy term as input and will attach to that node-bundle where you want to display it. Once you have it installed and created there are only four important and select-able properties.


I think what you are looking for is to show nodes which are related to current viewed node based on terms associated to that node. It can be achieved by creating a view with contextual filters “Content: Has taxonomy term ID (with depth)” and “Content: Has taxonomy term ID depth modifier”.

You can view detail instruction in this blog post - Create related content block view based on terms in Drupal 7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.