Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Vaporizin on December 27, 2014, 09:13:07 PM

Title: Best way to display UserID in Navigation Bar
Post by: Vaporizin on December 27, 2014, 09:13:07 PM
I would like for the UserID in a tab on the nav bar. I already placed UserID here under avatars like so;
(http://i.imgur.com/a9RTFPl.png)

I know how to make and edit tabs, but not too sure on how to make UserID show up there.
Title: Re: Best way to display UserID in Navigation Bar
Post by: Arantor on December 27, 2014, 09:15:08 PM
I'm curious... why?
Title: Re: Best way to display UserID in Navigation Bar
Post by: Vaporizin on December 27, 2014, 10:32:00 PM
User always ask for their User ID for several reasons and I'd like it to be displayed to them.
Title: Re: Best way to display UserID in Navigation Bar
Post by: Hj Ahmad Rasyid Hj Ismail on December 27, 2014, 11:59:11 PM
The code is already there, in the Display.template.php. Basically you can simply use $message['member']['id'] in there to call for the User ID.
Title: Re: Best way to display UserID in Navigation Bar
Post by: Antechinus on December 28, 2014, 12:21:12 AM
That won't work in the nav bar, since the nav bar is in index.template.php and doesn't reference $message stuffz.
Title: Re: Best way to display UserID in Navigation Bar
Post by: Hj Ahmad Rasyid Hj Ismail on December 28, 2014, 12:37:18 AM
Sorry. I did't read properly. I think there is one topic that deals with that before. May be you can search?

I use $context['user']['id'] in QRR mod after globalizing $context. You should be able to use that too.
Title: Re: Best way to display UserID in Navigation Bar
Post by: Vaporizin on December 28, 2014, 03:09:28 AM
Quote from: ahrasis on December 28, 2014, 12:37:18 AM
Sorry. I did't read properly. I think there is one topic that deals with that before. May be you can search?

I use $context['user']['id'] in QRR mod after globalizing $context. You should be able to use that too.
'title' => $context['user']['id'], resulted in this:
(http://i.imgur.com/FlydTjm.png)

Yeah, we're getting there, that's what I want. However, I need to let people know why that number is there.

So I simply added the  'UserID' , bit in the code like: 'title' => 'UserID:' , $context['user']['id'], and it results in this:
(http://i.imgur.com/dnEDbkF.png)
Doesn't show the number at all next to "UserID"
This is in Sources/Subs.php
Title: Re: Best way to display UserID in Navigation Bar
Post by: Hj Ahmad Rasyid Hj Ismail on December 28, 2014, 05:44:25 AM
Better give the whole code that you add plus few line above and below. It is really not clear on how you added it. Plus you need to use a dot (.), not a comma (,).
Title: Re: Best way to display UserID in Navigation Bar
Post by: Vaporizin on December 28, 2014, 02:50:56 PM
Quote from: ahrasis on December 28, 2014, 05:44:25 AM
Better give the whole code that you add plus few line above and below. It is really not clear on how you added it. Plus you need to use a dot (.), not a comma (,).
Yep, fatal mistake. Used the dot and now it works.

Still learning though.