1

I have a page like example.com/abcd.php?url=efg with Apache aliasing it to example.com/product/efg. I don't want certain blocks to be visible on this page; when I use product/efg in the block section, it does not take any effect. I wanted to know how to go about this issue.

1

If example.com/product/efg is a path alias, then you need to use the path that uses that alias in the block visibility settings.

For example, if example.com/product/efg is the alias for example.com/node/1, then you need to add node/1 in the list of pages where the block should not be shown.

If you have more path aliases for the same internal URL, then instead of setting the pages where the block should not be shown, you need to use PHP code that returns TRUE when the block needs to be shown. Code similar to the following one should work:

<?php
  return request_uri() != '/product/efg';
?>

If Drupal is executed in a subdirectory of the web server root directory, e.g. dr6, the code needs to be modified as follows:

<?php
  return request_uri() != '/dr61/product/efg';
?>

The reason I didn't use drupal_get_path_alias() is that the function returns just one of the path aliases existing for the internal path passed as argument; in the case there are more path aliases, this would be a problem.

1
  • My problem is tht there are other products like example.com/product/xyz on which the block needs to be shown and only for example.com/product/efg it should not be shown
    – Hacker
    Jul 9 '11 at 15:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.