Exclude a block from the views result I've created a views page named "Search" with a path of "product-page". Then I created a views block named "Sponsored Ads".

With the "Search" page, I exposed some fields for the filtering, then assigned the "Sponsored Ads" into the region and shows to only page listed "product-page".

I only want to display the "Sponsored Ads" into the "product-page" only, then exclude it from the results with "?"
(Eg. /product-page?title=test&amp;field_category_tid=All)

How can I achieve this? Please help...
There are actually quite a few methods on how to do this. The method here is quick and easy to do.

Install the devel module (you will uninstall it when your site goes live).

Make sure the block visibility settings is set up to only show on product-page.

Then add this code to your theme's template.php file.

function MYTHEME_block_view_alter(&amp;$data, $block) {
  dpm($block);
  if ($block-&gt;module == 'views' &amp;&amp; $block-&gt;delta == "BLOCK_DELTA") {
    //hide the block
    $params = drupal_get_query_parameters();
    if(count($params) &gt; 0) {
      $data["content"] = FALSE;
    }
  }
}


Change MYTHEME to your theme's name, and clear your cache.

Now you need to change BLOCK_DELTA with the delta of your block. To do that you will need to inspect the dpm output, and find your block, then find the delta of your block.



To further assist you in finding your block delta, you can inspect the block in question in your browser, and look at the id of the block. It will contain the delta as a substring with just the hyphens altered.



My delta is block_content-block so my line of code will be:

if ($block-&gt;module == 'views' &amp;&amp; $block-&gt;delta == "block_content-block") {


When you are done remove the line dpm($block);. You may then uninstall devel module if you wish. This code is a primer and you can adjust it if you need, but as is it will work.