1
boftx
How do put the username into a custom block?
  • 2008/12/4 0:25

  • boftx

  • Just popping in

  • Posts: 8

  • Since: 2008/11/27


Is there a way to use a variable such as {X_UNAME} in a custom block or do you need to use a PHP block and access internal variables? I want to have something like "Hi (username)!" and haven't found anyway to do it yet. I expect I need to use PHP.

On a related note, is there a list of all the tags like {X_SITENAME} that can be used in custom blocks?

2
mjoel
Re: How do put the username into a custom block?
  • 2008/12/5 0:44

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


<{if $xoops_isuser}>
Hi<{$xoops_uname}>.&nbsp;
<
a href="<{$xoops_url}>/user.php">Your 
                  Account 
a>&nbsp;|&nbsp;<a href="<{$xoops_url}>/user.php?op=logout">Logouta>
 <{else}>
Welcome Guest. <a href="<{$xoops_url}>/register.php">Registera> &nbsp;|&nbsp;<a href="<{$xoops_url}>/user.php">Sign Ina
                  <{/if}>


you can do this in your theme

try paste the code above in theme.html (themes/urtheme/)




3
trabis
Re: How do put the username into a custom block?
  • 2008/12/5 1:35

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

On a related note, is there a list of all the tags like {X_SITENAME} that can be used in custom blocks?


you can look inside kernel/block.php
function getContent($format 'S'$c_type 'T')
    {
        switch ( 
$format ) {
        case 
'S':
            if ( 
$c_type == 'H' ) {
                return 
str_replace('{X_SITEURL}'XOOPS_URL.'/'$this->getVar('content''N'));
            } elseif ( 
$c_type == 'P' ) {
                
ob_start();
                echo eval(
$this->getVar('content''N'));
                
$content ob_get_contents();
                
ob_end_clean();
                return 
str_replace('{X_SITEURL}'XOOPS_URL.'/'$content);
            } elseif ( 
$c_type == 'S' ) {
                
$myts =& MyTextSanitizer::getInstance();
                
$content str_replace('{X_SITEURL}'XOOPS_URL.'/'$this->getVar('content''N'));
                return 
$myts->displayTarea($content01);
            } else {
                
$myts =& MyTextSanitizer::getInstance();
                
$content str_replace('{X_SITEURL}'XOOPS_URL.'/'$this->getVar('content''N'));
                return 
$myts->displayTarea($content00);
            }
            break;
        case 
'E':
            return 
$this->getVar('content''E');
            break;
        default:
            return 
$this->getVar('content''N');
            break;
        }
    }


As you can see the only available inside blocks is {X_SITEURL}

If you want more then you will have to code them inside this method.

4
Anonymous
Re: How do put the username into a custom block?
  • 2008/12/5 2:45

  • Anonymous

  • Posts: 0

  • Since:


and class/xoopsblock.php too

5
boftx
Re: How do put the username into a custom block?
  • 2008/12/5 5:16

  • boftx

  • Just popping in

  • Posts: 8

  • Since: 2008/11/27


Thanks for the tips! I'm not fond of hacking a system file, but no biggie. I would suspect that there are a number of standard values that would be useful to have available in blocks, maybe it can be generalized in a module.

Thanks again!

Login

Who's Online

318 user(s) are online (247 user(s) are browsing Support Forums)


Members: 0


Guests: 318


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