1
khuhner
X_USERNAME (like X_SITEURL)?
  • 2006/2/9 4:39

  • khuhner

  • Quite a regular

  • Posts: 232

  • Since: 2006/1/6 3


I'm trying to populate the user name in a custom HTML block. While editing the XOOPS page says use {X_SITEURL} to display your site. How do I find out what the other options are? I'd like to display the username but think it's overkill to create PHP module just for this?

So is there a coresponging code/tag/label to get the user name? I've looked high and low and could only find references to <{$xoops_user}> (BTW didnt work for my needs). What is the difference of these two? How can I determine what other variables are at my disposal?

2
Catzwolf
Re: X_USERNAME (like X_SITEURL)?
  • 2006/2/9 5:23

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


in your PHP file
$member_handler = &xoops_gethandler( 'member' );
$user = $member_handler->getUser( $uid );
if (is_object($user ) and !empty($user ))
{
$xoopsTpl -> assign( 'my_username', $user -> getVar( 'username' ) );
}
in your html template

<{$my_username}>

3
frankblack
Re: X_USERNAME (like X_SITEURL)?
  • 2006/2/9 5:34

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


Hi John_N, not what he wanted I guess!

I would say look for X_SITEURL in class/xoopsblock.php and kernel/block.php and make there something like:

$member_handler = &xoops_gethandler'member' );
$user $member_handler->getUser$uid );
if (
is_object($user ) and !empty($user ))
{
return 
str_replace('{X_USERNAME}'$user -> getVar'username' ), $this->getVar('content''N'));
} else {
return 
str_replace('{X_USERNAME}''Guest'$this->getVar('content''N'));
}

4
Catzwolf
Re: X_USERNAME (like X_SITEURL)?
  • 2006/2/9 5:37

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Bah! Your getting to good at this for your own good. Same thing really, but in another way :-p

5
frankblack
Re: X_USERNAME (like X_SITEURL)?
  • 2006/2/9 5:50

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


Quote:
Same thing really, but in another way :-p


Yourself a !

Didn't he say "custom HTML block"? A smarty won't work there.

6
khuhner
Re: X_USERNAME (like X_SITEURL)?
  • 2006/2/9 18:42

  • khuhner

  • Quite a regular

  • Posts: 232

  • Since: 2006/1/6 3


Quote:
Didn't he say "custom HTML block"? A smarty won't work there.


I did indeed :) I was looking for the HTML code; didnt want to take the extra effort of converting the block from HTML to PHP JUST to get this token...

Thanks for BOTH your replies! I'll try the suggestion (from FrankBlack) tonite.

Thanks again!
Kurt

7
khuhner
Re: X_USERNAME (like X_SITEURL)?
  • 2006/2/10 23:11

  • khuhner

  • Quite a regular

  • Posts: 232

  • Since: 2006/1/6 3


Quote:
I would say look for X_SITEURL in class/xoopsblock.php and kernel/block.php and make there something like:

$member_handler = &xoops_gethandler'member' );
$user $member_handler->getUser$uid );
if (
is_object($user ) and !empty($user ))
{
return 
str_replace('{X_USERNAME}'$user -> getVar'username' ), $this->getVar('content''N'));
} else {
return 
str_replace('{X_USERNAME}''Guest'$this->getVar('content''N'));
}


I'm a little perplexed....do I create a seperate function for this code? I'm still a little new to XOOPS (bit not programming) so any details you can provide is good!

Thanks again!
Kurt

8
khuhner
Re: X_USERNAME (like X_SITEURL)?
  • 2006/2/17 23:28

  • khuhner

  • Quite a regular

  • Posts: 232

  • Since: 2006/1/6 3



Login

Who's Online

260 user(s) are online (159 user(s) are browsing Support Forums)


Members: 0


Guests: 260


more...

Donat-O-Meter

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

Latest GitHub Commits