Hi,

What ami trying is i have a content type called model which has two fields Model Number and Model image.

Now i have created a media gallery(View as block) which displays The model number and Model image but the problem here is
i wanted to display this view only on A3 which is a product page(the hierarchy is something like this Products/A1/A2/A3)

I tried the following php code
1)if (arg(0) == 'node') { return arg(1); }
return '';

2)return arg(1);

3)$path = drupal_get_path_alias($_GET['q']); //get alias of URL
$path = explode('/', $path); //break path into an array
print 'xxxxxxxxxxxxxxx'.$path;
//user print_r($path); to see what the $path array looks like
if ($path[0] == 'node' && $path[1] != '') {
return $path[1];
}

None of the above works for me --it doesnt display the Media Gallery block on A3 product page?
Where ami i going wrong here ?

Comments

danielb’s picture

I am having trouble understanding your post. This is what I understand your question to be:

You want a block to show on the path "Products/A1/A2/A3" where A1/A2/A3 are arguments to a view

Then simply use the block visibility settings and type in some PHP code

<?php

if (strtolower(arg(0)) == 'products' && arg(1) && arg(2) && arg(3)) {
  return TRUE;
}
return FALSE;


?>

However the code you posted does not even vaguely address this problem, so I may have misunderstood your question.

danielb’s picture

OH I think I understand. Product/A1/A2/A3 is the alias of the node?

In that case the code to put in block visibility settings is this:

<?php

$path = explode('/', drupal_get_path_alias($_GET['q']));
if (strtolower($path[0]) == 'products' && isset($path[1]) && isset($path[2]) && isset($path[3])) {
  return TRUE;
}
return FALSE;

?>