I have a "Related Articles" view block that is in use on the site, and it functions fine. The site's original dev team configured everything through templates, but the code is placed in the "Article" template properly, and it all is well. This is a standard Related Articles block that uses the contextual filter "Content: Has taxonomy term ID" to find other nodes of Article type with the same taxonomy terms.

I have a problem, though, creating a similar block for a recently created content type ("News"). This node type's display is configured through Panels, though I'm not sure if that's what's causing the issue. I cloned the original block and altered the (non-contextual) filter to select content based on whether the content type is either Article or News (the original does only Article). Everything else is the same, including the contextual filters. When I place this block in the News panel, I get no results in the block (I've double-checked to make sure I'm using terms that exist on other articles).

I'm sure there are a number of things that could be causing the issue, but I don't know where to look. Can you offer me any guidance?

Thank you.


Here is their php code. I'm not proficient in php, but this looks pretty barebones to me.

<?php print '<div class="contextual-links-region panel-pane pane-views pane-slideshow-displays contextual-links-region fusion-block-title-gray-text-red clear"><h2 class="pane-title block-title">Related Stories</h2><div class="pane-content content">' . views_embed_view('related_stories', 'block') . '</div></div>'; ?>


I have tried placing the following php into the panel:

$node = menu_get_object();
if (is_object($node)) {
  $tid = $node->field_article_tags['und'][0]['value'];
  $output = views_embed_view('related_articles_for_news_', 'block', $tid);
echo $output;

Still no luck. Everything looks correct to me. The URL on the view as I edit it is:


and this is the only display in the View. The advanced settings say that the machine name is "block", and I confirmed that field_article_tags is correct.

Additionally, I accidentally left off the trailing underscore in the view title originally, and, of course, that did not work either.

Any thoughts as to where I might be going wrong?

Thanks again.

1 Answer 1


The problem is that, your view accepts a Term ID which it uses to get other nodes tagged with the same term. But when you are placing the views block (accepting TID asparameter) in Panels, how are you passing the context to it?

This is probably why your dev went in for the code based approach. I think you can create a custom PHP panels content, grab the node from the present path, then grab the tid from term reference field, and the pass in the tid as context while calling the view through views_embed_view() function.

If you want you can paste the code your dev used and I can help you how you can re use the code in panels to get the same result.

Code Should be something like this:

$node = menu_get_object();
if (is_object($node)) {
  $tid = $node->field_yourfieldname['und'][0]['value'];
  $output = views_embed_view('your view name', 'display name', $tid);
echo $output;

Put the above code in the panel, using a custom content with PHP.

  • Ok, so if I understand correctly, even though the block is on the same page, it can't read the tag information from the node? (Adding the other code to OP now)
    – rrr45
    Commented Oct 9, 2013 at 19:51
  • updated my answer.
    – Neo
    Commented Oct 9, 2013 at 20:04
  • Still not working. See my second edit. Still getting nothing returned from the php.
    – rrr45
    Commented Oct 10, 2013 at 15:06
  • $tid = $node->field_article_tags['und'][0]['value']; should be $tid = $node->field_article_tags['und'][0]['tid']; This might not be the only error but still you can try that and let me know before i dig further.
    – Neo
    Commented Oct 10, 2013 at 15:19
  • That did it. Thanks very much for the help. So, to clarify, blocks just can't take contextual information from nodes on their own without it being fed manually via php such at this? How does that original line of code that I pasted in OP work in that case (see my first edit)?
    – rrr45
    Commented Oct 10, 2013 at 16:12

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.