I am trying to configure a block so that it only display on a particular page. The page is created using views and has a path of sitename/viewtest
under block config i have tried both sitename/viewtest and viewtest under the only show block on specific page but it is not showing up.
am i doing something wrong!?!?

Comments

viralagrawal’s picture

even I m facing the same problem.
Please someone help.
thanks

vikramy’s picture

Show if the following PHP code returns TRUE (PHP-mode, experts only).

$url = request_uri();
if (strpos($url, "viewtest")) {
return TRUE;
}
viralagrawal’s picture

thanks for the help..
actually I was making silliest of all mistakes..
I was putting a 'slash' prior to the path and that was preventing it from working..

I was writing /test/argument instead of test/argument..

2dareis2do’s picture

This seemed to work for me but I have the same problem where the uri ends ?page=1

e.g.

/en/press_release_en

/ar/press_release_ar

works but

/en/press_release_en?page=1

does not.

Anyone know why this is not working in Drupal?

Anonymous’s picture

I'm not sure, but you could try path/pagename*
I know that wildcards work in similar situations.

2dareis2do’s picture

To be more exact, this is not working with Drupal page views in Drupal 7.

Works fine in 6.

taggartj’s picture

in the php block visibility

I got some thing like this which works for a specific url (views page) and a node id (normal node )
and a taxonomy term id

  // This snippet returns TRUE if the node we are
  // currently viewing is tagged with a term which is
  // the 'desired_term' and we are not in edit mode (arg(2)).

  // put here the term ID you're interested in
$desired_term = 17;

// get the url   
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

// find the url if it contains works with ?get=some_thing (views filter)
$myurl = 'http://somefullurl.com/somepath';

if (strlen(stristr($actual_link,$myurl))>0) {
// url Found
return TRUE;
}
  if ( arg(0) == 'node' and is_numeric(arg(1)) and arg(2) == FALSE ) {
    // Yes, we're viewing a node in view mode.

    $node = node_load(arg(1)); // cached
	// if node id = some thing 
	  if ($node->nid =="14") {
	  return TRUE;
	  }
    // If the term does not exist we're done
    if (is_array($node->taxonomy)) {
      foreach ($node->taxonomy as $term) {
        if ($term->tid == $desired_term) {
          return TRUE;
        }
      }
    }
  }
  
  return FALSE;
  // works D6X

Now my question is how do you target the view page (the correct way )
some thing like: if ($view->view_title ='the_view_name'){ }
still scratching my head

wooody’s picture

Hi,
What If Iam using Ajax in my Views and I want show the Block only in first page in the my view

  $url = request_uri();
  $pos = strpos($url, "page");
  if ($pos === false && arg(0) =='portfolio') {
    return TRUE;
   }
 

What I need to add more ..?