I don't know much (any) PHP, though I am somewhat capable with C++ and HTML and have briefly studied VB. I have installed the 'Me' Alias module on my site.

I am trying to get a Block (which has links to all the user's custom content) to display only on a user's My Account page. I tried setting the path for the block to show up as both "user/me" and "user" but neither worked. It shows up for "user/*" but then the block is on every user page, which is largely undesirable.

Equally workable though probably harder would be to have a menu item show up only on (any) User pages.

Is there any simple solution? Thanks very much.

Comments

nedjo’s picture

global $user;
// Return TRUE if we have a user viewing her/his own user profile.
return $user->uid && arg(0) == 'user' && is_numeric(arg(1)) && arg(1) == $user->uid;
IceCreamYou’s picture

That looks like it should work... now if only my User 1 account hadn't abruptly nixed itself for no apparent reason. :/

What would I add to that snippet if I also wanted to include a page at the address /mymenu? I apologize for my total lack of knowledge about syntax here, I know it's fairly easy to add a simple "|| {$page==mymenu}" command.

nedjo’s picture

which I used in the snippet above.

http://api.drupal.org/api/function/arg/5

In this case, you would use arg(0), which would return the first segment of the current path:


if (arg(0) == 'mymenu') {
  
}

In general, when trying to do something in Drupal, you can start by looking for a similar snippet in Drupal core (the files included with the core Drupal download) and adapt from there.