11
raskolt
Re: Saying Hello to Xoops signed in user
  • 2006/8/6 9:28

  • raskolt

  • Just popping in

  • Posts: 17

  • Since: 2006/3/2 2


Quote:

skenow wrote:
declare $xoopsUser as a global variable in your PHP code. You can then access the various attributes of the user with something like this

$username $xoopsUser->getVar('uname');


See this for more information.


Thanks a lot Steve. This works fine If I could complete the module and if it works, I will write your name to the credits.

12
skenow
Re: Saying Hello to Xoops signed in user
  • 2006/8/10 2:14

  • skenow

  • Home away from home

  • Posts: 993

  • Since: 2004/11/17


@khuhner - sorry I didn't reply sooner, staying busy.

The '$username = ...' statement is for use in a php file (where all the programming and logic goes). It, in turn, will pass information to the html files that display your pages.

<{$xoops_uname}> is a smarty variable that can be used in module and block html files like text. I hadn't tried it in a custom block, but when I did, I found it wasn't being interpreted correctly. Adding it to another block by editing it's template did produce the desired results.

Perhaps someone more knowledgeable about how the custom blocks are generated by XOOPS can explain what needs to be done to display smarty tags in custom blocks.

13
wcrwcr
Re: Saying Hello to Xoops signed in user
  • 2006/9/8 8:22

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Hi

Quote:
<{$xoops_uname}> is a smarty variable that can be used in module and block html files like text. I hadn't tried it in a custom block, but when I did, I found it wasn't being interpreted correctly. Adding it to another block by editing it's template did produce the desired results.


is there a way to make a html or even a php custom block that greets a signed user?

I played a bit with the code spotted here but..........no love

Thanks

14
canbula
Re: Saying Hello to Xoops signed in user
  • 2006/9/8 8:27

  • canbula

  • Just popping in

  • Posts: 42

  • Since: 2006/7/10


in a custom php block..you can use this codes

echo "Welcome, ".$xoopsUser->getVar('uname');
hhttp://www.xoops-tr.com - Turkish Xoops

15
wcrwcr
Re: Saying Hello to Xoops signed in user
  • 2006/9/8 8:53

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Thanks canbula for your reply but if i just insert that code I get a "Returning" message and nothing happens.

It seems that i?m not allowed to create that block.

Wierd indeed

16
canbula
Re: Saying Hello to Xoops signed in user
  • 2006/9/8 9:01

  • canbula

  • Just popping in

  • Posts: 42

  • Since: 2006/7/10


$_SESSION['xoopsUserId'] this variable absolutely gets the user id..with this id you can get other thins that belongs the user..for example;

SELECT FROM xoops_users WHERE uid=".$_SESSION['xoopsUserId']." ORDER BY uname ASC limit 1


like this query you can get all the information about the user..but I don't know how it can be used in a block..because its mentality is realy different
hhttp://www.xoops-tr.com - Turkish Xoops

17
wcrwcr
Re: Saying Hello to Xoops signed in user
  • 2006/9/8 9:25

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


I?ve tried

mysql_query=SELECT FROM xoops_users WHERE uid=".$_SESSION['xoopsUserId'];
print "
xoopsUserId";


But the block doesn?t shows up

18
canbula
Re: Saying Hello to Xoops signed in user
  • 2006/9/8 10:40

  • canbula

  • Just popping in

  • Posts: 42

  • Since: 2006/7/10


you didn't understand me..look at this

include("mainfile.php");
    
$yol XOOPS_DB_HOST;
    
$kullanici_adi XOOPS_DB_USER;
    
$kullanici_sifre XOOPS_DB_PASS;
    
$veritabani_adi XOOPS_DB_NAME;
    
$veritabani_oneki XOOPS_DB_PREFIX;
    
$veri_yolu mysql_connect($yol$kullanici_adi$kullanici_sifre);
    if ( ! 
$veri_yolu ) die ("An error occured!");
    
mysql_select_db($veritabani_adi $veri_yolu) or die ("An error occured!" mysql_error() );
    
$sonuc mysql_query("SELECT * FROM ".$veritabani_oneki."_users WHERE uid=".$_SESSION['xoopsUserId']." ORDER BY uname ASC limit 1",$veri_yolu);
    while(
$satir mysql_fetch_array($sonuc)) {
        echo 
$satir['uname'];
    }
    
mysql_close();
?>


put this code in an external php file located in your XOOPS root directory..and call this file after login..you will see your user name
hhttp://www.xoops-tr.com - Turkish Xoops

19
Peekay
Re: Saying Hello to Xoops signed in user
  • 2006/9/8 11:41

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Or you could just put this in a PHP block...
global $xoopsUser;

if (
$xoopsUser) {
  
//User is logged in, display welcome message
  
$uname $xoopsUser->getVar('uname');
  echo(
"Welcome, $uname");
} else {
  return 
false;
}
A thread is for life. Not just for Christmas.

20
wcrwcr
Re: Saying Hello to Xoops signed in user
  • 2006/9/8 17:35

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Hi

@canbula & peekay

Thank you guys for your time

I?m using the peekay approach and everything is running smooth.

Thanks,
Wilson

Login

Who's Online

281 user(s) are online (136 user(s) are browsing Support Forums)


Members: 0


Guests: 281


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