Show profile on the navigation bar
+4
skouliki
YoshiGM
TonnyKamper
RafaelS
8 posters
Page 1 of 1
Show profile on the navigation bar
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
Control Panel >> Modules >> HTML and Javascript >> Management of Javascript codes >> Create a new javascript
Placement: On all pages
Author: RafaelS.
Working forum versions: All versions, except AwesomeBB
Application Result
The application will look as follows after being applied to the forum: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> ';} // 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> </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;}});
Re: Show profile on the navigation bar
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 AwesomeBBApplication Result
The application will look as follows after being applied to the forum: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> ';} // 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> </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
Am I allowed to translate this and share it on the Dutch support forum? Giving you de credits offcourse
Have a nice day
Re: Show profile on the navigation bar
I’m glad you enjoyed it and of course you are allowed @TonnyKamper, I see no problem there.
Re: Show profile on the navigation bar
RafaelS wrote:I’m glad you enjoyed it and of course you are allowed @TonnyKamper, I see no problem there.
Thank you very much @RafaelS it's done and you can check your credits here at the bottom: Avatar met profiellink op navbar
Props to you
Re: Show profile on the navigation bar
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
EDIT: Don't worked
Thanks.
If you don't have any problem, i will translate your code to Spanish and of course give you the respective credits
EDIT: Don't worked
Re: Show profile on the navigation bar
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
Re: Show profile on the navigation bar
Oh, it's already solved! I was trying to do it about a week. Thanks, bro.
deleted by skouliki
deleted by skouliki
Re: Show profile on the navigation bar
TonnyKamper wrote:Thank you very much @RafaelS it's done and you can check your credits here at the bottom: Avatar met profiellink op navbar
Props to you
@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
Re: Show profile on the navigation bar
Hi @skouliki I'm a bit confused, was your question for a test account addressed to me?
Re: Show profile on the navigation bar
yes sorry i didnt use the quote option ..i think you can succeed what you asked with some margin modificationTonnyKamper wrote:Hi @skouliki I'm a bit confused, was your question for a test account addressed to me?
Re: Show profile on the navigation bar
thanks the position is not changing so you must modify the code i guessTonnyKamper wrote:@skouliki PM is sent thank you!
Re: Show profile on the navigation bar
Okay, so my question to RafaelS still stands, thank you for your assistance @skouliki
Re: Show profile on the navigation bar
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
Re: Show profile on the navigation bar
Okay, so my question to RafaelS still stands, thank you for your assistanceWow! 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
Re: Show profile on the navigation bar
oneSmile wrote:Okay, so my question to RafaelS still stands, thank you for your assistanceWow! 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
Again, please stop hijacking threads unless you are providing support to the issue. This is considered spam. Thank you!
Re: Show profile on the navigation bar
@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.
Guest- Guest
Re: Show profile on the navigation bar
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?
Regards,
TC.
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)");
}
});
});
Regards,
TC.
Re: Show profile on the navigation bar
Thank you very much @TheCrow it does work but not as it's supposed to I think it doesn't take the avatar but the first picture underneath the navbar and also replaced some of the tabs with that picture..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)");
}
});
});
Regards,
TC.
- Example picture inside:
Any idea how to fix this?
Re: Show profile on the navigation bar
@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.
I'll check to fix that later on today.
Regards,
TC.
Re: Show profile on the navigation bar
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 , the "Under Construction" is just a message in the announcements section.. I thought that it shouldn't interfere with anything else, am I wrong?
Re: Show profile on the navigation bar
@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.
Regards,
TC.
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!
Re: Show profile on the navigation bar
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?
Re: Show profile on the navigation bar
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:
I'm glad to help you.
Feel free to contact me, if you have any further questions.
@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.
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> ';} // 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> </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.
@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.
Re: Show profile on the navigation bar
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> ';} // 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> </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.
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 ?
Re: Show profile on the navigation bar
@TonnyKamper,
Everything is possible.
I've done something very quick here, don't expect much:
Glad to help.
Everything is possible.
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> ';} // 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> ';} // 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.
Re: Show profile on the navigation bar
@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.
TC.
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!
Similar topics
» [QUERY] How to show the members' group joined in their post profile and even in their profile?
» what should i do to show profile on the forum toolbar
» Show Profile Fields on hover
» Signature will not show in profile menu
» Show Profile Edits in Moderator Log
» what should i do to show profile on the forum toolbar
» Show Profile Fields on hover
» Signature will not show in profile menu
» Show Profile Edits in Moderator Log
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum