The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
+4
skouliki
YoshiGM
TonnyKamper
RafaelS
8 posters

    Show profile on the navigation bar

    RafaelS
    RafaelS
    Forumember


    Posts : 123
    Reputation : 14
    Language : PT, EN, FR
    Location : Portuguese Support

    Show profile on the navigation bar Empty Show profile on the navigation bar

    Post by RafaelS 24/7/2018, 03:21

    Enable by means of this script the addition of a button with the user's name and avatar to the navigation bar, which will redirect to the user's profile.

    Author: RafaelS.
    Working forum versions: All versions, except AwesomeBB

    Application Result

    The application will look as follows after being applied to the forum:

    Show profile on the navigation bar LJqSE6k

    Installation

    The installation is unique, and can only be done by creating a new javascript. CSS can be modified, and is embedded in Javascript. Please follow the steps below to install the effect on your community.

    Control Panel >> Modules >> HTML and Javascript >> Management of Javascript codes >> Create a new javascript

    Placement: On all pages

    Code:
    /****
     * Application: Link and avatar in the navbar
     * Description: This application can show the link to the user's profile and avatar in the navbar.
     * Version: 1.0
     * Made and Optimizations by RafaelS. - 2018/07/06
     * View more in: https://ajuda.forumeiros.com
     * Copyright (c) 2018 RafaelS.<rafael_s at outlook dot pt>
     * This work is free. You can redistribute it and/or modify it
     * under the terms of the WTFPL, Version 2
     **/
     
    $(function() {
    if(_userdata.session_logged_in > 0) {
     
     Â var username = _userdata.username, userid = _userdata.user_id,navb,linkav = _userdata.avatar,prependcode = '<li><a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a></li>';
     Â 
    if($('body#modernbb').length > 0) navb = '.navbar.navlinks'; // ModernBB version
    else if($('td.bodyline').length > 0){navb = '.bodyline table:eq(1) tr td';prependcode = '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a> &nbsp;';} // phpBB2 version
    else if($('body#phpbb').length > 0){ navb = '.navbar .linklist.navlinks';prependcode = '<li><a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a> &nbsp;</li>';} // phpBB3 version
    else if($('.pun #pun-intro').length > 0)navb = '#pun-navlinks ul.clearfix';// punBB version
    else if($('#ipbwrapper').length > 0){ navb = '#submenu ul li'; prependcode= '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a>';} // Invision version
    else return; // no valid version
     Â 
    $('head').append(
     Â   '<style type="text/css">' +
     Â   '.mainmenu.rafavatar img {' +
     Â   'display: inline-block !important;'+
     Â   'width:30px;' +
     Â   'height: 30px;' +
     Â   'vertical-align: middle;' +
     Â   'border-radius: 16px;'    +
     Â   'margin-right: 7px;'    +
     Â   'box-shadow: 0 2px 2px rgba(0,0,0,0.1);' +
     Â  'filter: none;' +
     Â   '}' +
     Â   '</style>'
     Â );
     Â 
    $(navb).prepend(prependcode);
    }else{return;}});
    TonnyKamper
    TonnyKamper
    Active Poster


    Female Posts : 1080
    Reputation : 78
    Language : Dutch/English
    Location : DSF Admin

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TonnyKamper 24/7/2018, 23:38

    RafaelS wrote:Enable by means of this script the addition of a button with the user's name and avatar to the navigation bar, which will redirect to the user's profile.

    Author: RafaelS.
    Working forum versions: All versions, except AwesomeBB

    Application Result

    The application will look as follows after being applied to the forum:

    Show profile on the navigation bar LJqSE6k

    Installation

    The installation is unique, and can only be done by creating a new javascript. CSS can be modified, and is embedded in Javascript. Please follow the steps below to install the effect on your community.

    Control Panel >> Modules >> HTML and Javascript >> Management of Javascript codes >> Create a new javascript

    Placement: On all pages

    Code:
    /****
     * Application: Link and avatar in the navbar
     * Description: This application can show the link to the user's profile and avatar in the navbar.
     * Version: 1.0
     * Made and Optimizations by RafaelS. - 2018/07/06
     * View more in: https://ajuda.forumeiros.com
     * Copyright (c) 2018 RafaelS.<rafael_s at outlook dot pt>
     * This work is free. You can redistribute it and/or modify it
     * under the terms of the WTFPL, Version 2
     **/
     
    $(function() {
    if(_userdata.session_logged_in > 0) {
     
     Â var username = _userdata.username, userid = _userdata.user_id,navb,linkav = _userdata.avatar,prependcode = '<li><a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a></li>';
     Â 
    if($('body#modernbb').length > 0) navb = '.navbar.navlinks'; // ModernBB version
    else if($('td.bodyline').length > 0){navb = '.bodyline table:eq(1) tr td';prependcode = '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a> &nbsp;';} // phpBB2 version
    else if($('body#phpbb').length > 0){ navb = '.navbar .linklist.navlinks';prependcode = '<li><a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a> &nbsp;</li>';} // phpBB3 version
    else if($('.pun #pun-intro').length > 0)navb = '#pun-navlinks ul.clearfix';// punBB version
    else if($('#ipbwrapper').length > 0){ navb = '#submenu ul li'; prependcode= '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a>';} // Invision version
    else return; // no valid version
     Â 
    $('head').append(
     Â   '<style type="text/css">' +
     Â   '.mainmenu.rafavatar img {' +
     Â   'display: inline-block !important;'+
     Â   'width:30px;' +
     Â   'height: 30px;' +
     Â   'vertical-align: middle;' +
     Â   'border-radius: 16px;'    +
     Â   'margin-right: 7px;'    +
     Â   'box-shadow: 0 2px 2px rgba(0,0,0,0.1);' +
     Â  'filter: none;' +
     Â   '}' +
     Â   '</style>'
     Â );
     Â 
    $(navb).prepend(prependcode);
    }else{return;}});

    Wow this works flawless on my Invision forum @RafaelS awesome job Yes

    Show profile on the navigation bar Avatar10

    Am I allowed to translate this and share it on the Dutch support forum? Giving you de credits offcourse Smile

    Have a nice day bye
    RafaelS
    RafaelS
    Forumember


    Posts : 123
    Reputation : 14
    Language : PT, EN, FR
    Location : Portuguese Support

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by RafaelS 25/7/2018, 04:37

    I’m glad you enjoyed it and of course you are allowed @TonnyKamper, I see no problem there. Very Happy
    TonnyKamper
    TonnyKamper
    Active Poster


    Female Posts : 1080
    Reputation : 78
    Language : Dutch/English
    Location : DSF Admin

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TonnyKamper 25/7/2018, 22:31

    RafaelS wrote:I’m glad you enjoyed it and of course you are allowed @TonnyKamper, I see no problem there. Very Happy

    Thank you very much @RafaelS cheers it's done and you can check your credits here at the bottom: Avatar met profiellink op navbar

    Props to you Very good ~1~ salut
    YoshiGM
    YoshiGM
    Active Poster


    Male Posts : 1557
    Reputation : 146
    Language : Spanish & English
    Location : Mexico

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by YoshiGM 26/8/2018, 05:59

    Wow! This is very cool! You can avoid some clicks to check your profile.
    Thanks.

    If you don't have any problem, i will translate your code to Spanish and of course give you the respective credits Wink

    EDIT: Don't worked silent
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15311
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by skouliki 25/3/2019, 18:24

    Moulds965 wrote:The only thing I need now is a way for the providers (those who can post to the main blog) a way to create/edit posts. Other than adding a meta widget to the sidebar, is there a better way I can provide authors, contributors, etc.

    please open a new thread with your issue giving all details and your forum url

    EdwinWeatherford
    EdwinWeatherford
    New Member


    Posts : 2
    Reputation : 1
    Language : English

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by EdwinWeatherford 21/6/2019, 16:51

    Oh, it's already solved! I was trying to do it about a week. Thanks, bro.

    deleted by skouliki
    TonnyKamper
    TonnyKamper
    Active Poster


    Female Posts : 1080
    Reputation : 78
    Language : Dutch/English
    Location : DSF Admin

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TonnyKamper 21/6/2019, 18:11

    TonnyKamper wrote:Thank you very much @RafaelS cheers it's done and you can check your credits here at the bottom: Avatar met profiellink op navbar

    Props to you Very good  ~1~  salut


    @RafaelS is there any chance we can position it right before the profile button instead of at the very beginning of the navbar?


    Last edited by TonnyKamper on 21/6/2019, 18:18; edited 1 time in total
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15311
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by skouliki 21/6/2019, 18:14

    hi

    do you have a test account ..send it to me

    TonnyKamper
    TonnyKamper
    Active Poster


    Female Posts : 1080
    Reputation : 78
    Language : Dutch/English
    Location : DSF Admin

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TonnyKamper 21/6/2019, 18:21

    Hi @skouliki I'm a bit confused, was your question for a test account addressed to me?  Confused
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15311
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by skouliki 21/6/2019, 18:26

    TonnyKamper wrote:Hi @skouliki I'm a bit confused, was your question for a test account addressed to me?  Confused
    yes sorry i didnt use the quote option ..i think you can succeed what you asked with some margin modification

    TonnyKamper
    TonnyKamper
    Active Poster


    Female Posts : 1080
    Reputation : 78
    Language : Dutch/English
    Location : DSF Admin

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TonnyKamper 21/6/2019, 18:43

    @skouliki PM is sent  Smile  thank you!
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15311
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by skouliki 21/6/2019, 19:00

    TonnyKamper wrote:@skouliki PM is sent  Smile  thank you!
    thanks the position is not changing so you must modify the code i guess

    TonnyKamper
    TonnyKamper
    Active Poster


    Female Posts : 1080
    Reputation : 78
    Language : Dutch/English
    Location : DSF Admin

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TonnyKamper 21/6/2019, 19:05

    Okay, so my question to RafaelS still stands, thank you for your assistance @skouliki Flowers
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15311
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by skouliki 24/6/2019, 16:57

    Harvey14 wrote:I’m using ProfileGrid user managing plugin, and since it’s a brand new plugin, the technical documentation is very poor. Any help would be appreciated. Thank you!

    your issue is not related to forumotion therefore we can not give any help
    please note that spamming is not tolerated


    oneSmile
    oneSmile
    New Member


    Posts : 3
    Reputation : 1
    Language : english

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by oneSmile 26/9/2019, 23:17

    Wow! This is very cool! You can avoid some clicks to check your profile.
    Thanks.

    If you don't have any problem, i will translate your code to Spanish and of course give you the respective credits Wink

    Okay, so my question to RafaelS still stands, thank you for your assistance
    Draxion
    Draxion
    Helper
    Helper


    Male Posts : 2518
    Reputation : 321
    Language : English
    Location : USA

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by Draxion 26/9/2019, 23:23

    oneSmile wrote:
    Wow! This is very cool! You can avoid some clicks to check your profile.
    Thanks.

    If you don't have any problem, i will translate your code to Spanish and of course give you the respective credits Wink

    Okay, so my question to RafaelS still stands, thank you for your assistance

    Again, please stop hijacking threads unless you are providing support to the issue. This is considered spam. Thank you!
    avatar
    Guest
    Guest


    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by Guest 27/9/2019, 00:19

    @Moulds965 , @oneSmile and @Harvey14 are all spam bots. 2 of them have links to external websites in their posts, and the 3rd will probably add one later.
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TheCrow 6/10/2019, 01:20

    Hello there and excuse me for the intrusion here.

    My initial thought was, why have your name there at the very beginning of the navigation bar, since you could just change it and make it simply replace the "Profile" navigation button option with the user's name and avatar?

    Something I've done using Ajax, just because I am not a very "pro" javascript person but I've managed my ways throughout the years. So if possible, what @TonnyKamper is asking would be great, but with an addition of replacing the existing profile button.

    Also, a quick question. How is this way any better (other than loading instantly) than the ajax way?
    Code Inside:
    Smile

    Regards,
    TC.
    TonnyKamper
    TonnyKamper
    Active Poster


    Female Posts : 1080
    Reputation : 78
    Language : Dutch/English
    Location : DSF Admin

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TonnyKamper 6/10/2019, 05:50

    TheCrow wrote:Hello there and excuse me for the intrusion here.

    My initial thought was, why have your name there at the very beginning of the navigation bar, since you could just change it and make it simply replace the "Profile" navigation button option with the user's name and avatar?

    Something I've done using Ajax, just because I am not a very "pro" javascript person but I've managed my ways throughout the years. So if possible, what @TonnyKamper is asking would be great, but with an addition of replacing the existing profile button.

    Also, a quick question. How is this way any better (other than loading instantly) than the ajax way?
    Code Inside:
    Smile

    Regards,
    TC.
    Thank you very much @TheCrow it does work but not as it's supposed to I think Think it doesn't take the avatar but the first picture underneath the navbar and also replaced some of the tabs with that picture..

    Example picture inside:

    Any idea how to fix this? Confused
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TheCrow 7/10/2019, 11:11

    @TonnyKamper this happens because you have the "Under Construction" message there. That is considered a module and that's why it gets that image. As soon as you remove that it'll work perfectly.

    I'll check to fix that later on today.

    Regards,
    TC.
    TonnyKamper
    TonnyKamper
    Active Poster


    Female Posts : 1080
    Reputation : 78
    Language : Dutch/English
    Location : DSF Admin

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TonnyKamper 7/10/2019, 17:37

    TheCrow wrote:@TonnyKamper this happens because you have the "Under Construction" message there. That is considered a module and that's why it gets that image. As soon as you remove that it'll work perfectly.

    I'll check to fix that later on today.

    Regards,
    TC.

    THank you @TheCrow I hope you'll succeed Very Happy , the "Under Construction" is just a message in the announcements section.. I thought that it shouldn't interfere with anything else, am I wrong?
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TheCrow 7/10/2019, 20:10

    @TonnyKamper it doesn't unless you use a script like mine that gets the first image and text in a module. Codewise, the announcements are made in modules and that's why it interferes with the code.

    Regards,
    TC.



    Show profile on the navigation bar Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    TonnyKamper
    TonnyKamper
    Active Poster


    Female Posts : 1080
    Reputation : 78
    Language : Dutch/English
    Location : DSF Admin

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TonnyKamper 7/10/2019, 23:53

    Ah okay @TheCrow so if I would take the picture out of the message it should work? So that would mean one can never post pictures in the announcements section anymore when using your script?
    RafaelS
    RafaelS
    Forumember


    Posts : 123
    Reputation : 14
    Language : PT, EN, FR
    Location : Portuguese Support

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by RafaelS 8/10/2019, 01:36

    Hello @TonnyKamper, @oneSmile, @TheCrow

    Sorry guys, I've been away for a long time.
    For those who wanted to replace the default "profile" menu by this new button, please use the following code, instead:

    Code:
    /****
     * Application: Link and avatar in the navbar
     * Description: This application can show the link to the user's profile and avatar in the navbar.
     * Version: 1.0
     * Made and Optimizations by RafaelS. - 2018/07/06
     * View more in: https://ajuda.forumeiros.com
     * Copyright (c) 2018 RafaelS.<rafael_s at outlook dot pt>
     * This work is free. You can redistribute it and/or modify it
     * under the terms of the WTFPL, Version 2
     **/
     
    $(function() {
    if(_userdata.session_logged_in > 0) {
     
      var username = _userdata.username, userid = _userdata.user_id,navb,linkav = _userdata.avatar,prependcode = '<li><a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a></li>';
     
    if($('body#modernbb').length > 0) navb = '.navbar.navlinks'; // ModernBB version
    else if($('td.bodyline').length > 0){navb = '.bodyline table:eq(1) tr td';prependcode = '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a> &nbsp;';} // phpBB2 version
    else if($('body#phpbb').length > 0){ navb = '.navbar .linklist.navlinks';prependcode = '<li><a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a> &nbsp;</li>';} // phpBB3 version
    else if($('.pun #pun-intro').length > 0)navb = '#pun-navlinks ul.clearfix';// punBB version
    else if($('#ipbwrapper').length > 0){ navb = '#submenu ul li'; prependcode= '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a>';} // Invision version
    else return; // no valid version
     
    $('head').append(
        '<style type="text/css">' +
        '.mainmenu.rafavatar img {' +
        'display: inline-block !important;'+
        'width:30px;' +
        'height: 30px;' +
        'vertical-align: middle;' +
        'border-radius: 16px;'    +
        'margin-right: 7px;'    +
        'box-shadow: 0 2px 2px rgba(0,0,0,0.1);' +
      'filter: none;' +
        '}' +
        '</style>'
      );
     
    $('li a.mainmenu[href*="profile"]').html(prependcode);
    }else{return;}});

    I'm glad to help you.
    Feel free to contact me, if you have any further questions. Smile




    @TheCrow, why would you use ajax to get the avatar? There is no need to, as there is a variable who does it for you.
    In my eyes, my approach is much more efficient. But well, let's not argue about that. king
    TonnyKamper
    TonnyKamper
    Active Poster


    Female Posts : 1080
    Reputation : 78
    Language : Dutch/English
    Location : DSF Admin

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TonnyKamper 8/10/2019, 18:47

    RafaelS wrote:Hello @TonnyKamper, @oneSmile, @TheCrow

    Sorry guys, I've been away for a long time.
    For those who wanted to replace the default "profile" menu by this new button, please use the following code, instead:

    Code:
    /****
     * Application: Link and avatar in the navbar
     * Description: This application can show the link to the user's profile and avatar in the navbar.
     * Version: 1.0
     * Made and Optimizations by RafaelS. - 2018/07/06
     * View more in: https://ajuda.forumeiros.com
     * Copyright (c) 2018 RafaelS.<rafael_s at outlook dot pt>
     * This work is free. You can redistribute it and/or modify it
     * under the terms of the WTFPL, Version 2
     **/
     
    $(function() {
    if(_userdata.session_logged_in > 0) {
     
      var username = _userdata.username, userid = _userdata.user_id,navb,linkav = _userdata.avatar,prependcode = '<li><a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a></li>';
     
    if($('body#modernbb').length > 0) navb = '.navbar.navlinks'; // ModernBB version
    else if($('td.bodyline').length > 0){navb = '.bodyline table:eq(1) tr td';prependcode = '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a> &nbsp;';} // phpBB2 version
    else if($('body#phpbb').length > 0){ navb = '.navbar .linklist.navlinks';prependcode = '<li><a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a> &nbsp;</li>';} // phpBB3 version
    else if($('.pun #pun-intro').length > 0)navb = '#pun-navlinks ul.clearfix';// punBB version
    else if($('#ipbwrapper').length > 0){ navb = '#submenu ul li'; prependcode= '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a>';} // Invision version
    else return; // no valid version
     
    $('head').append(
        '<style type="text/css">' +
        '.mainmenu.rafavatar img {' +
        'display: inline-block !important;'+
        'width:30px;' +
        'height: 30px;' +
        'vertical-align: middle;' +
        'border-radius: 16px;'    +
        'margin-right: 7px;'    +
        'box-shadow: 0 2px 2px rgba(0,0,0,0.1);' +
      'filter: none;' +
        '}' +
        '</style>'
      );
     
    $('li a.mainmenu[href*="profile"]').html(prependcode);
    }else{return;}});

    I'm glad to help you.
    Feel free to contact me, if you have any further questions. Smile



    Wow that is awesome @RafaelS that works like a charm, I have one more question:
    Would it be possible to add a dropdownlink to it directing to the edit profile page to make it completely perfect ?
    RafaelS
    RafaelS
    Forumember


    Posts : 123
    Reputation : 14
    Language : PT, EN, FR
    Location : Portuguese Support

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by RafaelS 9/10/2019, 00:17

    @TonnyKamper,

    Everything is possible. Show profile on the navigation bar 1f60e
    I've done something very quick here, don't expect much:

    Code:
    /****
     * Application: Link and avatar in the navbar
     * Description: This application can show the link to the user's profile and avatar in the navbar.
     * Version: 2.0
     * Made and Optimizations by RafaelS. - 2019/10/08
     * View more in: https://ajuda.forumeiros.com
     * Copyright (c) 2018 RafaelS.<rafael_s at outlook dot pt>
     * This work is free. You can redistribute it and/or modify it
     * under the terms of the WTFPL, Version 2
     **/
     
    $(function() {
    if(_userdata.session_logged_in > 0) {
     
      var username = _userdata.username, userid = _userdata.user_id,navb,linkav = _userdata.avatar,prependcode = '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a>';
      var edit = $('li a.mainmenu[href*="profile"]').attr("href");
     
    if($('body#modernbb').length > 0) navb = '.navbar.navlinks'; // ModernBB version
    else if($('td.bodyline').length > 0){navb = '.bodyline table:eq(1) tr td';prependcode = '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a> &nbsp;';} // phpBB2 version
    else if($('body#phpbb').length > 0){ navb = '.navbar .linklist.navlinks';prependcode = '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a> &nbsp;';} // phpBB3 version
    else if($('.pun #pun-intro').length > 0)navb = '#pun-navlinks ul.clearfix';// punBB version
    else if($('#ipbwrapper').length > 0){ navb = '#submenu ul li'; prependcode= '<a class="mainmenu rafavatar" href="/u'+userid+'"><span id="img">'+linkav+'</span>'+username+'</a>';} // Invision version
    else return; // no valid version
     
    $('head').append(
        '<style type="text/css">' +
        '.mainmenu.rafavatar img {' +
        'display: inline-block !important;'+
        'width:30px;' +
        'height: 30px;' +
        'vertical-align: middle;' +
        'border-radius: 16px;'    +
        'margin-right: 7px;'    +
        'box-shadow: 0 2px 2px rgba(0,0,0,0.1);' +
      'filter: none;' +
        '}' +
         'li.rafhover .rafedit{display:block!important;position:absolute}li.rafhover{position:relative;display:inline-block!important}'+
        '</style>'
      );
     
    $('li a.mainmenu[href*="profile"]').parent("li").html(prependcode).append('<a style="display:none" class="mainmenu rafedit" href="'+edit+'">Edit profile</a>');

    $('.mainmenu.rafavatar').parent("li").hover(function() {
       $(this).toggleClass("rafhover");
    });

    }else{return;}});

    Glad to help. Smile
    TonnyKamper
    TonnyKamper
    Active Poster


    Female Posts : 1080
    Reputation : 78
    Language : Dutch/English
    Location : DSF Admin

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TonnyKamper 9/10/2019, 01:00

    Oops @RafaelS this made all other navlinks disappear lol!

    Show profile on the navigation bar Avatar11
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Show profile on the navigation bar Empty Re: Show profile on the navigation bar

    Post by TheCrow 9/10/2019, 14:57

    @RafaelS i wouldn't argue because I know ajax is not efficient. But this is what I managed to do thus far. Thank you for the code. Best regards.

    TC.



    Show profile on the navigation bar Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!

      Current date/time is 23/9/2024, 02:13