I've learned how to display a block only in the currently logged on user's profile page (http://drupal.org/node/134433)
But what if I want it to display on a couple other pages also? Don't know how to do that.

Comments

jrowny’s picture

You can list pages under the block visibility pages. Just list all the pages you want there and use * as a wildcard.

jerseycheese’s picture

You could an an elseif to that code:

<?php
global $user;
if (arg(0) == 'user' && $user->uid == arg(1)){
  return TRUE;
}
elseif(arg(0) == 'node' && arg(1) == '12') {
  return TRUE;
}
else {
  return FALSE;
}
?>

In that case, the block would show on the specific page at node/12. It depends what the path for the page is in that type of situation. node/12 would be the full display of a given node.

Does that work in your situation? If not, where do you need it to display?

bigfool007’s picture

sorry.no smile

aharown07’s picture

Yes, the elseif approach should work. Will be a cpl days before I get a chance to test it, but it make sense.
Thanks!
One question though, what would the condition look like if the page is not a node? For example, how about the main forum page? Not sure what variable to use there.

jerseycheese’s picture

I'm pretty sure it would be:

<?php
global $user;
if (arg(0) == 'user' && $user->uid == arg(1)){
  return TRUE;
}
elseif(arg(0) == 'forum') {
  return TRUE;
}
else {
  return FALSE;
}
?>

arg(0) refers to the first part (argument) of the URL path after the domain name. arg(1) is the second part. And so on.

aharown07’s picture

Yes, that works. Many thanks!

Just out of curiosity (since I'm learning something here) how would I display on the front page? Tried 'front' and '' and 'frontpage' but none of these work.

dalegrebey’s picture

One option is to:

- Enabled the default frontpage view (views of course)
- And than assign that path to your default front page through your admin settings: admin/settings/site-information.

jerseycheese’s picture

http://api.drupal.org/api/function/drupal_is_front_page/6

You can use the handy drupal_is_front_page() function from the API to check if a page is the front page. So...

<?php
global $user;
if (arg(0) == 'user' && $user->uid == arg(1)){
  return TRUE;
}
elseif(drupal_is_front_page()) {
  return TRUE;
}
else {
  return FALSE;
}
?>
aharown07’s picture

Didn't know about drupal_is_front_page
Very handy