ulrisa
Posts: 8
|
| Posted: 07/03/2008, 12:43 PM |
|
Hi. I guess this is a stupid question..
I need to pass a value from php to html..
Ive looked for info and foud this but it doesent work.
What i want is that welcome shall contain the logged in users id but it wont work att all why?
Really need help!
html {welcome}
php
global $Tpp;
$Tpp->SetVar('welcome', $_SESSION[UserID]);
|
 |
 |
datadoit
|
| Posted: 07/03/2008, 6:23 PM |
|
ulrisa wrote:
> Hi. I guess this is a stupid question..
>
> I need to pass a value from php to html..
>
> Ive looked for info and foud this but it doesent work.
>
> What i want is that welcome shall contain the logged in users id but it wont
> work att all why?
>
> Really need help!
>
> html {welcome}
>
> php
> global $Tpp;
> $Tpp->SetVar('welcome', $_SESSION[UserID]);
> ---------------------------------------
Should be $Tpl, not $Tpp.
|
|
|
 |
ulrisa
Posts: 8
|
| Posted: 07/04/2008, 2:25 AM |
|
Can i use another variable name or is $Tpl the onley allowed?
|
 |
 |
ulrisa
Posts: 8
|
| Posted: 07/04/2008, 2:25 AM |
|
Can i use another variable name or is $Tpl the onley allowed?
|
 |
 |
jjrjr1
Posts: 942
|
| Posted: 07/04/2008, 2:39 AM |
|
Hi
The value must be $Tpl and you must set it as global.
The reason is thet $Tpl is the object that is defined to be the HTML template the PHP code is placing values into.
So is you have the string {welcome} in your HTML the setvar method for $Tpl will replace it.
EG:
HTML:
<a href="code.php?value={welcome}>Say Hello</a>
The PHP code:
global $Tpl;
$Tpl->SetVar('welcome', $_SESSION[UserID]);
will replace all occurences of {welcome} to the value of $_SESSION[UserId]);
Does that make sense and help a little.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
ulrisa
Posts: 8
|
| Posted: 07/04/2008, 3:10 AM |
|
Thanks, that was very helpful.
But then ihave a problem $Tpl is already used in my index.php can i declare another variable in the HTML template?
Ulrik
|
 |
 |
jjrjr1
Posts: 942
|
| Posted: 07/04/2008, 6:21 AM |
|
Yes $Tpl is always used. It is in every php file.
$Tpl is NOT the variable in the HTML template. It IS the HTML template.
$Tpl is an object that contains the entire template. setvar() is a method for the $Tpl object.
$Tpl->SetVar() with replace in the HTML the value specified like in the example I posted above.
You can put any number or {xxx} {xyyy} you want into the HTML code itself and setvar() will replace it with whatever value you specify.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |