Show profile on the navigation bar

Go down

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

Post by RafaelS on July 23rd 2018, 10:21 pm

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;}});
RafaelS
RafaelS
New Member

Posts : 18
Reputation : 10
Language : Portuguese, English and French

http://ajuda.forumeiros.com/forum

Back to top Go down

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

Post by TonnyKamper on July 24th 2018, 6:38 pm

@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
TonnyKamper
TonnyKamper
Forumember

Female Posts : 539
Reputation : 45
Language : Dutch/English
Location : The Netherlands

http://www.nederlandheelt.nl/forum

Back to top Go down

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

Post by RafaelS on July 24th 2018, 11:37 pm

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

Posts : 18
Reputation : 10
Language : Portuguese, English and French

http://ajuda.forumeiros.com/forum

Back to top Go down

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

Post by TonnyKamper on July 25th 2018, 5:31 pm

@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
TonnyKamper
TonnyKamper
Forumember

Female Posts : 539
Reputation : 45
Language : Dutch/English
Location : The Netherlands

http://www.nederlandheelt.nl/forum

Back to top Go down

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

Post by YoshiGM on August 26th 2018, 12:59 am

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
YoshiGM
YoshiGM
Forumember

Male Posts : 837
Reputation : 115
Language : Spanish & English
Location : Mexico

http://asistencia.foroactivo.com/u21373

Back to top Go down

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

Post by skouliki on March 25th 2019, 12:24 pm

@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
skouliki
skouliki
Manager
Manager

Female Posts : 6942
Reputation : 1017
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

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

Post by EdwinWeatherford on June 21st 2019, 11:51 am

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

Show profile on the navigation bar 110
EdwinWeatherford
EdwinWeatherford
New Member

Posts : 2
Reputation : 1
Language : English

https://forumexiet.com

Back to top Go down

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

Post by TonnyKamper on June 21st 2019, 1:11 pm

@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 June 21st 2019, 1:18 pm; edited 1 time in total
TonnyKamper
TonnyKamper
Forumember

Female Posts : 539
Reputation : 45
Language : Dutch/English
Location : The Netherlands

http://www.nederlandheelt.nl/forum

Back to top Go down

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

Post by skouliki on June 21st 2019, 1:14 pm

hi

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

Female Posts : 6942
Reputation : 1017
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

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

Post by TonnyKamper on June 21st 2019, 1:21 pm

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

Female Posts : 539
Reputation : 45
Language : Dutch/English
Location : The Netherlands

http://www.nederlandheelt.nl/forum

Back to top Go down

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

Post by skouliki on June 21st 2019, 1:26 pm

@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
skouliki
skouliki
Manager
Manager

Female Posts : 6942
Reputation : 1017
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

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

Post by TonnyKamper on June 21st 2019, 1:43 pm

@skouliki PM is sent  Smile  thank you!
TonnyKamper
TonnyKamper
Forumember

Female Posts : 539
Reputation : 45
Language : Dutch/English
Location : The Netherlands

http://www.nederlandheelt.nl/forum

Back to top Go down

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

Post by skouliki on June 21st 2019, 2:00 pm

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

Female Posts : 6942
Reputation : 1017
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

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

Post by TonnyKamper on June 21st 2019, 2:05 pm

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

Female Posts : 539
Reputation : 45
Language : Dutch/English
Location : The Netherlands

http://www.nederlandheelt.nl/forum

Back to top Go down

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

Post by skouliki on June 24th 2019, 11:57 am

@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

skouliki
skouliki
Manager
Manager

Female Posts : 6942
Reputation : 1017
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

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

Post by oneSmile on September 26th 2019, 6:17 pm

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
oneSmile
oneSmile
New Member

Posts : 3
Reputation : 1
Language : english

https://help.forumotion.com/register?step=2&agreement=1&

Back to top Go down

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

Post by Draxion on September 26th 2019, 6:23 pm

@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!


NEVER provide your founder's account or email
Please provide forum's URL when dealing with design and appearance issues
Don't forget to mark the topic as Show profile on the navigation bar Solved11 when the issue is resolved. This helps the staff greatly.
PM Support is prohibited!
TOS | General Rules | FAQ | Tricks & Tips | Latest Updates | Introduce Yourself

Show profile on the navigation bar Draxio14
Draxion
Draxion
Support Moderator
Support Moderator

Male Posts : 2380
Reputation : 301
Language : English
Location : USA

https://www.talesoftellene.com/

Back to top Go down

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

Post by Occultist on September 26th 2019, 7:19 pm

@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.
Occultist
Occultist
Forumember

Posts : 181
Reputation : 48
Language : English and couple others

https://idonthaveaforum.forumotion.com

Back to top Go down

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

Post by TheCrow on October 5th 2019, 8:20 pm

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:
Code:
$(function(){
  $.ajax({
    url: '/u' + _userdata.user_id,
    type: 'GET',
    success: function(profs){
      var avt = $('.module:eq(0) div img',profs).attr('src'),
          nme = $('.module:eq(0) div.h3',profs).text().replace('(online)','');
     
      $('a.mainmenu[href*="editprofile"] img').removeAttr('src');
      $('a.mainmenu[href*="editprofile"]').text(nme);
      $('<img class="theavatnav" src="' + avt + '" />').prependTo('a.mainmenu[href*="editprofile"]').css({'width':'30px','height':'30px','border-radius':'100%'}); 
     
    },
    error: function(err){
      console.log("AJAX error in request (Load Profile Info)");
    }
  }); 
});
Smile

Regards,
TC.
TheCrow
TheCrow
Energetic

Male Posts : 6109
Reputation : 706
Language : Greek, English
Location : Cyprus, Greece

https://www.inforumgr.com

Back to top Go down

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

Post by TonnyKamper on October 6th 2019, 12:50 am

@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:
Code:
$(function(){
  $.ajax({
    url: '/u' + _userdata.user_id,
    type: 'GET',
    success: function(profs){
      var avt = $('.module:eq(0) div img',profs).attr('src'),
          nme = $('.module:eq(0) div.h3',profs).text().replace('(online)','');
     
      $('a.mainmenu[href*="editprofile"] img').removeAttr('src');
      $('a.mainmenu[href*="editprofile"]').text(nme);
      $('<img class="theavatnav" src="' + avt + '" />').prependTo('a.mainmenu[href*="editprofile"]').css({'width':'30px','height':'30px','border-radius':'100%'}); 
     
    },
    error: function(err){
      console.log("AJAX error in request (Load Profile Info)");
    }
  }); 
});
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:
Show profile on the navigation bar Navbar10

Any idea how to fix this? Confused
TonnyKamper
TonnyKamper
Forumember

Female Posts : 539
Reputation : 45
Language : Dutch/English
Location : The Netherlands

http://www.nederlandheelt.nl/forum

Back to top Go down

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

Post by TheCrow on October 7th 2019, 6:11 am

@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.
TheCrow
TheCrow
Energetic

Male Posts : 6109
Reputation : 706
Language : Greek, English
Location : Cyprus, Greece

https://www.inforumgr.com

Back to top Go down

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

Post by TonnyKamper on October 7th 2019, 12:37 pm

@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?
TonnyKamper
TonnyKamper
Forumember

Female Posts : 539
Reputation : 45
Language : Dutch/English
Location : The Netherlands

http://www.nederlandheelt.nl/forum

Back to top Go down

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

Post by TheCrow on October 7th 2019, 3:10 pm

@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.
TheCrow
TheCrow
Energetic

Male Posts : 6109
Reputation : 706
Language : Greek, English
Location : Cyprus, Greece

https://www.inforumgr.com

Back to top Go down

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

Post by TonnyKamper on October 7th 2019, 6:53 pm

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?
TonnyKamper
TonnyKamper
Forumember

Female Posts : 539
Reputation : 45
Language : Dutch/English
Location : The Netherlands

http://www.nederlandheelt.nl/forum

Back to top Go down

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

Post by RafaelS on October 7th 2019, 8:36 pm

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
RafaelS
RafaelS
New Member

Posts : 18
Reputation : 10
Language : Portuguese, English and French

http://ajuda.forumeiros.com/forum

Back to top Go down

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

Post by TonnyKamper on October 8th 2019, 1:47 pm

@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 ?
TonnyKamper
TonnyKamper
Forumember

Female Posts : 539
Reputation : 45
Language : Dutch/English
Location : The Netherlands

http://www.nederlandheelt.nl/forum

Back to top Go down

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

Post by RafaelS on October 8th 2019, 7:17 pm

@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
RafaelS
RafaelS
New Member

Posts : 18
Reputation : 10
Language : Portuguese, English and French

http://ajuda.forumeiros.com/forum

Back to top Go down

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

Post by TonnyKamper on October 8th 2019, 8:00 pm

Oops @RafaelS this made all other navlinks disappear lol!

Show profile on the navigation bar Avatar11
TonnyKamper
TonnyKamper
Forumember

Female Posts : 539
Reputation : 45
Language : Dutch/English
Location : The Netherlands

http://www.nederlandheelt.nl/forum

Back to top Go down

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

Post by TheCrow on October 9th 2019, 9:57 am

@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.
TheCrow
TheCrow
Energetic

Male Posts : 6109
Reputation : 706
Language : Greek, English
Location : Cyprus, Greece

https://www.inforumgr.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum