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.
Options

Display UserPhoto in "Menu"

13»

Answers

  • Options

    I'll try to help tomorrow, But now that I read the discussion - Kasper may be the better person to see what you may be missing.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
  • Options
    peregrineperegrine MVP
    edited March 2013

    out of curiousity, did you try this, it works. if you want to add the logged in users photo to the menu bar.

    if you are using a .tpl file.

    {photo_link}

    or are using default.master.php

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    no its a default.master.php , if it was a tpl I would not be able to that I have not managed to find a way to avoid the rich text when I open to edit using a txt editor. Seems for those everything can be done through the theme hooks .

    I was able to add myself to the menu using the method from this thread, however that does not replace the text link as an image it just adds another image or link to the menu or close to the menu.

    I know I am close to getting this right, what is missing is the user img url I guess for now I just put a smiley and the name of the user appears in a dropdown with the link......

  • Options
    peregrineperegrine MVP
    edited March 2013

    if it was a tpl I would not be able to that I have not managed to find a way to avoid the rich text when I open to edit using a txt editor

    ?? just give it a .txt extension and change it when you upload it.

    the recommended way is to use themehooks and default.master.tpl (not default.master.php) - and why spin your wheels with themehooks, when you already have a built-in function to display the photo. But, i am always mystified.

    you can see the themes distributed with vanilla in 2.1 are .tpls as far as I know - that is the migration path php -> tpl in theme construction

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Yea you don't know how many times I tried that , many many it could be coz of my mac or the text editor is crap, I set it to be always text not rich text. When I open the tpl , it looks like rich text not much in there, even the vanilla link is in colors and underlined, you don't see the rest of the stuff if there is any ....

    so I reconstructed new ones and saved them as text then changed the extension to no avail just kept getting bonked .If anyone knows a mac text editor that works better than textedit let me know...

  • Options

    can you download openoffice or notepad++ or libreoffice.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited March 2013

    My mac thinks tpl files open with adobe elements that's how screwd up it is.. I have OpenOffice yea I will try with that see what happens with that ... even stickies would be fine lol

  • Options
    peregrineperegrine MVP
    edited March 2013

    copy the file from default.master.tpl to default.master.txt - edit save and rename.

    http://tamanmohamed.blogspot.com/2012/11/mac-alternatives-to-notepad-on-mac-os-x.html

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited March 2013

    default.master.txt actually I tried various combos.. I even set the file type to only open with text editor and it still recommends photoshop...Kasper uses a Mac I think he should have some idea

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    I will check those out and see what happens. thanks for that link :)

  • Options
    peregrineperegrine MVP
    edited March 2013

    I'll leave the explaining to Kasper for the themehooks.

    the only reason I see to use themehooks is to add php code easily to a non default.master.php theme (in other words for default.master.tpl based themes.)

    if you want to add a photo link via your default.master.php

    add this... where you want it located between the addlinks somewhere in default.master.php

    $myUser  = Gdn::Session()->User;
    $myUser = UserBuilder($myUser);
    $photo = UserPhoto($myUser, array('LinkClass' => 'ProfilePhotoCategory', 'ImageClass' => 'ProfilePhotoSmall'));
     echo $photo;
    

    there are a lots of ways to add it.

    or if you don't care about vanillicons.

    just

    echo Gdn_Theme::Link('photo');

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    Hmmm... Ain't sure why it's not working for you - it's works perfectly fine on my installation. Have you tried doing a var_dump() of VrijThemeHooks::User()? If not, try doing so and post the output.

    As for the .tpl files, it's not at all a problem on Mac - I wouldn't touch them on a Windows machine, I'm a Unix guy by nature. To open them, you'll need a good text editor though. I personally use Sublime Text 2; it's the best text editor for OS X by far.

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited March 2013

    @peregrine said: if you want to add a photo link via your default.master.php

    Yea that is what I have been trying to do, I know this thread started to be used with tpl , however I wanted to use the method or similar with php not tpl although I will also use it for that later, atm it's a default.master.php

    I got something working ....finally but...

    
    
     $myUser  = Gdn::Session()->User;
    $photo = UserPhoto($myUser, array('LinkClass' => 'ProfilePhotoCategory', 'ImageClass' => 'ProfilePhotoSmall'));
    
    
                                $this->Menu->AddLink('User', $photo,'/profile/{UserID}/{Username}',array('LinkClass' => 'ProfilePhotoCategory', 'ImageClass' => 'ProfilePhotoSmall'),array('Garden.SignIn.Allow'));                     
    

    This will add a user image where the text link for the name would be. I did not echo the link because it just shows up double and not in the right place. What I did however, adds another link without picture and makes the picture below it which is the same link arg !!

    When I see the source, it shows two links one after the other. If I delete the node on firebug the link takes it's rightful place... what a conundrum ??!!

    @kasperisager said: I wouldn't touch them on a Windows machine

    yea I know the feeling, I downloaded the text editor you suggested wow what a difference it makes compared to TextEdit !! Thank you very much

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited March 2013

    Ok well I managed to get this to work as I wanted but seems hackish to me however it works so I should not complain. What I did is this:

     $Authenticator = Gdn::Authenticator();
                            if ($Session->IsValid()) {
                                
                                $CountNotifications = $Session->User->CountNotifications;
                                if (is_numeric($CountNotifications) && $CountNotifications > 0)
                                    $photo .= ' '.$CountNotifications.'';
                                $photo = UserPhoto(Gdn::Session()->User);
       
    $this->Menu->AddLink('User',  $photo,  '/profile/{UserID}/{Username}',array('Garden.SignIn.Allow'), array('class' => 'UserNotifications'));
    
    

    That gave them classes so I then moved the image link a bit with css

    #Menu li.UserNotifications a.ProfileLink {
    top: -30px;
    }
    #Menu li.UserNotifications a.ProfileLink img{
    visibility: visible!important;
    width:30px!important;
    height:30px!important;
    box-shadow:none!important;
    border-radius:0!important;
    }
    

    I really thought I was just too stupid to get this lmao but I persevered and success !! me so happy :)

    Thanks @peregrine and @kasperisager for your patience and tips I send you much love your way besitos oxox !!

Sign In or Register to comment.