How can I tell a block to appear on user profiles, like /user/1
, but not on other pages where the beginning of the path is the same? So for instance, if I have a view set up at /user/1/articles
, or user/1/messages
, how can I tell the block to appear in the main user profile but not on the articles or messages pages?
Add a comment
|
2 Answers
I believe your only option is to use a PHP snippet to set the visibility.
Under Visibility settings
select Pages on which this PHP code returns TRUE (experts only)
copy and paste the snippet below.
<?php
if (arg(0) == 'user' && !arg(2)) return TRUE;
?>
For this to work you would also need to enable the PHP filter
module.
Note that it's not generally recommended to use the PHP filter, but in some cases it might be the easiest solution.
-
Yeah that ended up working. Why exactly is it not recommended to use the php filter?– MrweinerCommented Jan 20, 2013 at 5:09
-
1Check out this answer, and this page on drupal.org for the general reasons.– dxcCommented Jan 20, 2013 at 6:38