TepelStr33ltje schrieb am 30.12.2002 um 19:50 Uhr
i liked the principle of the magictemplate, but the came across a problem how to put a object in a template.
i found one way to do it that was put the object variable in another variableand put that variable in the template but is there a way to immediatly put the object in a template
bdominik schrieb am 30.12.2002 um 20:34 Uhr
What's your object? Is it an simple PHP-Code? Which normaly outputs your data via "echo"? And now you want to integrate this code into the template?
There are 2 solutions:
1. You wait for 2.81 (next version). Then you can integrate PHP-Code into the templates
2. You write the output into a variable insteed of echo'ing it!
I you have any problems with this solution, feel free and reply again.
Best regards
BD
TepelStr33ltje schrieb am 31.12.2002 um 02:56 Uhr
my object is one that i get with a mysql_fetch_object, and which i forgot to mension earlier put that object into an other array.
it then contains the users info and it would be easier and saver i guess if i could immediatly access it
here's an example:
if it works it should be in highlighting :P
<?
$query = "SELECT id,username,password FROM $user_table WHERE username='".$_POST["username"]."' ";
$sql = mysql_query($query) or die(mysql_error());
$User = mysql_fetch_object($sql);
// I work with sessions thus that should explane the below weirdness :P
$_SESSION["User"] = $User;
?>
OK it may look strange but it works and according to is save too
MagicTemplate does take normal objects like this $object->name but not an "array object"
and now you have a template ( a simple html file ) in which you call the object you made from the query
like so
<html>
<body>
Your name is $_SESSION[User]->username .
</body>
</html>
Bluetooth schrieb am 31.12.2002 um 10:23 Uhr
ah *wild flashing lamp over head*
no, object calling in templates is not supportet, the variable pasting is just a simple insert.
But why do you fetch the data as object? well, never mind ..
just as said, you have to output the object data into a plain variable and then add the variable to the template file.
TepelStr33ltje schrieb am 31.12.2002 um 14:52 Uhr
Bluetooth postete
ah *wild flashing lamp over head*
[..]
But why do you fetch the data as object? well, never mind ..
[...]
an object because its saver and i have to put it into an session but im trying to find antoher way WITHOUT cookies
TepelStr33ltje schrieb am 31.12.2002 um 15:46 Uhr
and i found out another thing MagicTemplate also has problems with the following variable in a template
$array[somthing][anotherthing]
it just prints out:
Array[anotherthing]
i discovered this when i tried to change mij login script
TheTinySteini schrieb am 31.12.2002 um 16:08 Uhr
Yes... actually, it's eval() that has problems with it. You might however try using ${array[something][else]}
I have not tested it, but I guess it might work. At least it's worth a try.
TepelStr33ltje schrieb am 31.12.2002 um 16:22 Uhr
${array[something][else]}
didnt work BUT
{$array[something][else]}
DID work
thnx