benutzerbild in navi
am 04.03.2011 - 21:32 Uhr in
Hallo ich suche einen PHP Code oder noch besser ein Modul womit ich im Navigationsmenü unterhalb des Benutzernamens das dazugehörige Benutzerbild angezeigt wird.
Hab ein paar codes ausprobiert.
Dieser englischsprachige User hatte das haargleiche Problem.
siehe hier:
User Pictures Above Navigation Block
Posted by GorillaSushi on January 22, 2007 at 5:42pm
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...
<?php
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
Login or register to post comments ⋅ Categories: Theme development,
Drupal 4.7.x
Comments
could you use Views to make
Posted by nickmaynard on January 22, 2007 at 6:03pm
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?
Login or register to post comments
might need $user variable?
Posted by krisvannest on January 22, 2007 at 7:06pm
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:
<?php
global $user;
if ($user->uid) {print ("Welcome, $user->name");}
else print ("Welcome, <a href=\"user\">log-in/join</a>");
?>
Perhaps there's a $user->picture type variable you can try/lookup?
Login or register to post comments
yes, try $user->picture
Posted by krisvannest on January 22, 2007 at 7:11pm
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:
<?php
global $user;
if ($user->uid) {print ("Welcome, $user->name <img src=\"$user->picture\">");}
else print ("<center>Welcome, <a href=\"user\">log-in/join</a></center>");
?>
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.
Login or register to post comments
Perfect! Thanks!
Posted by GorillaSushi on January 24, 2007 at 6:41pm
That's exactly what I needed!
My version ended up slightly different...
<?php
global $user;
if ($user->uid) {print ("<center><br /><img src=\"$user->picture\"><br /><br /></center>");}
else print ("<center><a href=\"/?q=user/register\"><img src=\"/images/noavatar.jpg\"></a></center>");
?>
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.
Die in diesem Post aufgeführten Php codes funktionieren sogar, aber die Bilder werden leider nicht immer angezeigt
Keine Ahnung woran es liegt.
Ab und zu logg ich mich aus und neu ein und dann funkts wieder mal aber dann zeigt ein anderer browser das bild wieder nicht an.. usw..
Kenn mich mit PHP leider überhaupt nicht aus..
Und mein bissl mit firebug experimentieren hat auch noch keine Früchte getragen.
Ein dementsprechendes Modul würde natürlich auch sehr weiterhelfen.
-fitzpatrick-
- Anmelden oder Registrieren um Kommentare zu schreiben
Neue Kommentare
vor 5 Stunden 1 Minute
vor 11 Stunden 58 Minuten
vor 22 Stunden 16 Minuten
vor 22 Stunden 35 Minuten
vor 22 Stunden 39 Minuten
vor 22 Stunden 43 Minuten
vor 23 Stunden 31 Minuten
vor 1 Tag 29 Minuten
vor 1 Tag 1 Stunde
vor 1 Tag 2 Stunden