By GorillaSushi on
I am looking to display the logged in user's picture above their name in the navigation block.
I'm using a theme based on box-gray. Currently the logged in user's name appears above the main navigation block. I would like the user's avatar to appear directly above it. User's who are not logged in would see the anonymous avatar.
I tried creating a block using...
if ($picture) {
print $picture;
}
but that didn't work. Would I need to find the PHP that already displays the name and and a snippet above it?
Thanks in advance
Jason - www.gorillasushi.com
Comments
could you use Views to make
could you use Views to make a block and have the filter be the current users picture? and make it only viewable to authenticated users?
might need $user variable?
Well i don't know too much about accessing $picture, but it might be that it refers to the picture of the node author, so since there is no node author per-se of navigation block you might have to actually get at it by pulling from the $user variable...
For example, here's some code to display the logged in user's name anywhere in a template:
Perhaps there's a $user->picture type variable you can try/lookup?
yes, try $user->picture
Just tested my above code and looks like it works; thanks for posting the question, too, because now after jotting the code it might be something I use myself. Here's an update of the above, but w/ additional code to display the currently logged in user's pic:
BTW, don't forget you need to escape any quotes you want to print via a PHP command by putting the \ just before them, as I did here.
Perfect! Thanks!
That's exactly what I needed!
My version ended up slightly different...
Mine shows only the picture using "br"s to center vertically. Users not logged in see the default avatar (noavatar.jpg) that links to the registration page.
Great, and I like your idea
Great, and I like your idea to display guest.jpg or noavatar.jpg.
BTW, I could be mistaken, but the
<center>tag *might* not be strictly compliant these days. I mean it prob works cross browser right now, but FWIW I thought I remember reading someplace that its use wasn't encouraged 'cause it might not be supported going forward.... if so, perhaps using CSS<span>to float it center (or some other means) would be something to think about down the road.Thanks for block code snippet
will be using it on one of my sites.
User's Profile Picture
Hi Gorilla... into what file did you insert the above code?
Thanks man!!!
It was the body of a block
It was the body of a block using PHP input format.
This can also be added to the
This can also be added to the navigation block above the navigation menu thus reducing the need for an extra block for one image alone.
size of image?
hello,
i created a new block for this as i do not know where to edit the navigation block but would prefer it though if i knew how to do this.
Using the aqua marina theme....
can someone help me with this one? Many thanks!
Esau