Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Ok user is logged in ..

422422 Developer MVP
edited December 2011 in Vanilla 2.0 - 2.8

I want to do three things....

  1. echo logged in users profile photo.
  2. echo logged in users username and href to their profile.
  3. echo messages received ( count ) and href to their messages.

Imagine, this to be on any or all pages.. so just wondering if anyone knows the code to do this.. Thanks

There was an error rendering this rich post.

«1

Answers

  • 422422 Developer MVP

    Am thinking we need to wrap this in an array.. But im no php guru lol

    There was an error rendering this rich post.

  • 422422 Developer MVP
    edited December 2011

    Ok I have username and url link ( i think I have done this correctly.

    < div class="myProfileName">< a href="<?php echo Url('/profile/'); ?>"><?php echo $Name; ?>< /a>< /div>
    

    hmm not sure this is correct actually..

    There was an error rendering this rich post.

  • 422422 Developer MVP

    Ok I think the above is fixed.

    < div class="myProfileName">< a href="<?php echo Url('/profile/'.$Name); ?>"><?php echo $Name; ?>< /a>< /div>

    There was an error rendering this rich post.

  • 422422 Developer MVP
    edited December 2011

    Ok now we have alert issue. The above code renders perfectly until we receive a notification.
    The output html looks like this...

    < div class="myProfileName">
    < a alert"="" href="/forum-theme/profile/admin < span class=">
    1">admin
    < span class="Alert">1< /span>
    < /a>
    < /div>
    

    There was an error rendering this rich post.

  • 422422 Developer MVP

    Ok I may have fixed this issue.

    < div class="myProfileName">< a href="<?php echo Url('/profile/'.$UserName) ?>"><?php echo $Name; ?>< /a>< /div>
    

    There was an error rendering this rich post.

  • 422422 Developer MVP

    Ok sheesh I am dumb, and slow but persistant..

    < div class="myProfileName">< a href="<?php echo Url('/profile/') ?>"><?php echo $Name; ?>< /a>< /div>
    

    Now to get notification alert for this part.. to link to messages all.
    Plus still need to echo users profile pic

    There was an error rendering this rich post.

  • clethrillclethrill ✭✭
    edited December 2011

    @422 if we leave this long enough will you figure it out all by yourself? For user photo (which also links to their profile) use...

    UserPhoto($Name)

  • 422422 Developer MVP

    Lol its a work in progress , i blog it so others can see what i am doing and what a knob i am lol

    Will try that thanks , do you know var for messages all with count like u see on inbox menu

    Inbox (3)

    There was an error rendering this rich post.

  • 422422 Developer MVP

    hmm so how would you render that UserPhoto on the page anywhere you want with associative url back to their profile ? I cannot get it to render correctly

    There was an error rendering this rich post.

  • clethrillclethrill ✭✭
    edited December 2011

    <a href="{link path="messages/inbox"}">Inbox {if $User.CountUnreadConversations} <span>{$User.CountUnreadConversations}</span>{/if}</a>

    that is in smarty....

  • clethrillclethrill ✭✭
    edited December 2011

    422 said:
    hmm so how would you render that UserPhoto on the page anywhere you want with associative url back to their profile ? I cannot get it to render correctly

    Well where you want it, you get the correct view for your theme and place echo UserPhoto($Name); should work

  • 422422 Developer MVP

    < am a noob.
    trying to echo currently logged in users photo. Say I wanted it in footer, or wherever.

    < div class="myPhoto">< img src="<?php echo Url(UserPhoto($Name)); ?>">< /div>
    

    There was an error rendering this rich post.

  • 422422 Developer MVP

    clethrill said:
    <a href="{link path="messages/inbox"}">Inbox {if $User.CountUnreadConversations} <span>{$User.CountUnreadConversations}</span>{/if}</a>

    that is in smarty....

    Yeah I dont use smarty.

    There was an error rendering this rich post.

  • 422 said:
    < am a noob.

    I ain't much better

    for the $Name to be currently logged on user you would use $Session->UserID = $Name (I just realised what a weird word session is) I think.

    For the messages $Name->CountUnreadConversations = $UnreadConvo not confident on that one, in the database there is only a countreadmessages

  • 422422 Developer MVP

    Well the name part I am sorted.. But can you echo currently logged in users avatar ? ( UserPhoto ) cos I sure as shit cant.

    I always thought Flange was a great word

    There was an error rendering this rich post.

  • I used to have this in my helper_functions view for my theme, but I didn't like it and there is a plugin for it anyway. It displays the first and last users to post in that discussions photos.

    15.   $Sender->EventArguments['Discussion'] = &$Discussion;
    17.   $First = UserBuilder($Discussion, 'First');
    18.   $Last = UserBuilder($Discussion, 'Last');
    

    ... a little bit later ...

    44.   echo UserPhoto($First);
    45.   if($Discussion->Comments > 1) 
    46.      echo UserPhoto($Last);
    

    and that worked perfectly fine

  • 422422 Developer MVP
    edited December 2011

    Yeah thats cool, i got that. But i want to echo userphoto of logged in user. I must be the worlds biggest noob, cos this has me beat

    There was an error rendering this rich post.

  • clethrillclethrill ✭✭
    edited December 2011
    $Session = Gdn::Session();
    $Session->UserID 
    

    ?

    The only place I have used the logged in users profile picture is in my minecraft theme, which uses smarty. minecraft-theme

    this markdown shit is confusing me

  • 422422 Developer MVP

    Annoying isnt it

    There was an error rendering this rich post.

  • 422422 Developer MVP

    Also noted that user links, have their userid like this:

    forum-theme/profile/2/username

    How do we parse the userid ? ... argghh is there anywhere in the documentation that helps play with these vars

    There was an error rendering this rich post.

Sign In or Register to comment.