News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Best way to display UserID in Navigation Bar

Started by Vaporizin, December 27, 2014, 09:13:07 PM

Previous topic - Next topic

Vaporizin

I would like for the UserID in a tab on the nav bar. I already placed UserID here under avatars like so;


I know how to make and edit tabs, but not too sure on how to make UserID show up there.

Arantor


Vaporizin

User always ask for their User ID for several reasons and I'd like it to be displayed to them.

Hj Ahmad Rasyid Hj Ismail

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.

Antechinus

That won't work in the nav bar, since the nav bar is in index.template.php and doesn't reference $message stuffz.

Hj Ahmad Rasyid Hj Ismail

#5
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.

Vaporizin

#6
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:


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:

Doesn't show the number at all next to "UserID"
This is in Sources/Subs.php

Hj Ahmad Rasyid Hj Ismail

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 (,).

Vaporizin

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.

Advertisement: