I have a tricky one here and looking for some suggestions.

I have a Page view which uses a contextual filter on the nid (which is in the URL).

These nodes have a term reference field which contain various terms.

I have a block which I only want to be displayed on this page if the node has this specific term referenced to it. Bare-in-mind this is not the actual node page, this a dynamically created page/view based on the nid in the url.

  • Are you using drupal 7? – rks Nov 15 '16 at 5:36
  • yes Drupal 7 mate – user43161 Nov 15 '16 at 8:27

Did you try php code? If you enable 'PHP filter' module, you can add php code under 'Pages restricted to certain pages' option in block configuration and write your code like

$relative_path = request_uri();
if (some condition)   {

    return TRUE;

    return FALSE;

| improve this answer | |

Please try below steps,

  1. Crearte a hook for the block display alter, hook_block_view_MODULE_DELTA_alter() // To alter specific block

  2. Inside the hook, render the view using below code, $my_view = views_get_view($my_view_name); // To get related Taxonomy term for the node

  3. Check if the Taxonomy term exists.

  4. Manage display/hide for the block.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy