1
Nootje
How to put logged in user name in block...
  • 2004/3/16 14:13

  • Nootje

  • Just popping in

  • Posts: 15

  • Since: 2004/3/16


Hi i've looked around on the forums for a bit but couldn't really find what I am looking for so I hope someone can help me.

I'm trying to put the username of the logged in person in the block of the user menu. So it will look something like:

_____________________
Username <-- Username of logged in user
_____________________

Administration Menu
View Account
Modify Account
Notifications
Inbox
Logout


The only way i have been able to make the default "User Menu" change is to change the name in the Admin > Blocks bit and change the title of it.

So if anyone knows how to make it work or knows if it is even possible, i'm all ears

Nootje

2
Mithrandir
Re: How to put logged in user name in block...

you can gain access to the user's details by putting this in the block code:
global $xoopsUser$xoopsConfig;

/*
Set name to anonymous if not logged in (Block shouldn't be visible for non-logged in visitors, but you never know)
*/
$name $xoopsConfig['anonymous']; 

/*
else get username from user object
*/
if ($xoopsUser) {
    
$name $xoopsUser->getVar('uname');
}

After this, you should be able to insert $name where you want it to be.

Note: I just looked into the code and see that the block uses a template. In a template, you can use <{$xoops_uname}> for displaying username

3
Nootje
Re: How to put logged in user name in block...
  • 2004/3/16 16:28

  • Nootje

  • Just popping in

  • Posts: 15

  • Since: 2004/3/16


Alrighty, so what template would i edit and where would i put <{$xoops_uname}> ?

4
Mithrandir
Re: How to put logged in user name in block...

the template to edit is system_block_user.html

Place the <{$xoops_uname}> where you want the name to appear.

5
Nootje
Re: How to put logged in user name in block...
  • 2004/3/16 16:50

  • Nootje

  • Just popping in

  • Posts: 15

  • Since: 2004/3/16


Well the name popped up this time, however its not where i actually wanted it. I placed at the very top of the template but this is what it looks like then:

_____________________
User Menu
_____________________
Username <-- Username of logged in user (works now)
Administration Menu
View Account
Modify Account
Notifications
Inbox
Logout

I would like it to be where User Menu is atm

6
Mithrandir
Re: How to put logged in user name in block...

that's the block's title - which is a little tricky to make dynamic, since it takes the title from the block management.

You need a way to hack the block title for this block only, to take the username instead of block title - that's not quite an easy task to do, I'm afraid.

7
Nootje
Re: How to put logged in user name in block...
  • 2004/3/16 20:25

  • Nootje

  • Just popping in

  • Posts: 15

  • Since: 2004/3/16


Well i'm a bit of a xoop-noob so... :(

Thanx for your help anyway Mithrandir.

Login

Who's Online

164 user(s) are online (116 user(s) are browsing Support Forums)


Members: 0


Guests: 164


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits