1
rboyle
How can I access Xoops variables in my page?
  • 2006/6/12 15:35

  • rboyle

  • Just popping in

  • Posts: 5

  • Since: 2006/5/15


Hi folks,

I've got a trial installation of XOOPS working and I like it a lot, but I have one critical problem: I need to access some XOOPS variables in my custom php page, e.g. <{$xoops_uname}>, but when I refer to it I just get "<{$xoops_uname}>" displayed rather than the actual username.

I'd really appreciate if someone knows if there is a module which I need to include in my PHP page, or if I somehow need to 'turn on' smarty variable access, or what?

Many thanks,

Antonia

2
Quest
Re: How can I access Xoops variables in my page?
  • 2006/6/12 19:36

  • Quest

  • Friend of XOOPS

  • Posts: 1034

  • Since: 2005/11/19


Do you have the mainfile.php and header.php included in your php file? That might do it for you. But based on what you have told us it could be a bunch of different various asundry of things.

Quest

3
jensclas
Re: How can I access Xoops variables in my page?

Please read the read B4U post link below and tell us your versions. If you want help you need to tell us fully about your problem.

4
rboyle
Re: How can I access Xoops variables in my page?
  • 2006/6/12 21:56

  • rboyle

  • Just popping in

  • Posts: 5

  • Since: 2006/5/15


Thanks for the replies guys

I call my php page /modules/testme.php via a menu item, and it displays perfectly, only I need to access the username of the person logged in, as follows:

Quote:

<?php

include(XOOPS_ROOT_PATH."/header.php");//xoops stuff
include(XOOPS_ROOT_PATH."/mainfile.php");//xoops stuff
include ("mainfile.php"); //just to be sure! I copied them into same directory
include ("header.php");

echo {$xoops_uname}; //this gives me a PHP error
echo $xoops_uname; // is blank
...
...

include(XOOPS_ROOT_PATH."/footer.php");
?>


Am I missing something obvious or how can I access the value of $xoops_uname (and other variables)

Many thanks

5
Defkon1
Re: How can I access Xoops variables in my page?
  • 2006/6/12 22:33

  • Defkon1

  • Not too shy to talk

  • Posts: 151

  • Since: 2005/1/27


in your php code you can directly use the $xoopsUser object:

echo $xoopsUser->getVar('uname');  //display username


Variables like <{$something}> are Smarty tags you can use in your themes.

6
Catzwolf
Re: How can I access Xoops variables in my page?
  • 2006/6/12 22:50

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


You really need to use the XOOPS template class for this. Look at other XOOPS modules for examples on how to use this class. It is easy to understand and the modules should give you a good understanding of how this should be put together.

example:

//template you will use for your module. There is also another method where you can read the template straight from the disk.   Again I suggest that you look for XOOPS_ROOT_PATH.'/class/templates'; in the files for examples off this in Xoops.
$xoopsOption['template_main'] = 'system_userform.html';
//Always include this file as it required for this to work //correctly $xoopsTpl is declared or I should say the call to //the class in in that file.
include 'header.php';

//assign a lang define to the template
$xoopsTpl->assign'lang_login'_LOGIN );
would be <{$lang_login}> in the template
Or you could do this instead and bypass using the assign for langauge defines <{$smarty.const._LOGIN }> and it would produce the same results

//assign a variable to the template
$xoopsTpl->assign'my_var'$my_var );
Would be <{$my_var}>

Smarty has so much to offer and is easy enough to learn.

Hope this little bit helps

7
rboyle
Re: How can I access Xoops variables in my page?
  • 2006/6/13 0:27

  • rboyle

  • Just popping in

  • Posts: 5

  • Since: 2006/5/15


Many thanks for your help and your time guys, it's working now.

I offer you a free surfing lesson as a reward!


Resized Image

Login

Who's Online

155 user(s) are online (122 user(s) are browsing Support Forums)


Members: 0


Guests: 155


more...

Donat-O-Meter

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

Latest GitHub Commits