|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Hpatoio Smarty Rookie
Joined: 29 Apr 2003 Posts: 25 Location: Italy
|
Posted: Thu Nov 06, 2003 8:38 pm Post subject: How do I access my properties ? |
|
|
if I extend smarty class like :
Code: |
class Smarty_MY extends Smarty {
var $a = "";
var $b = "";
function Smarty_MY() {
global $Root;
// Class Constructor. These automatically get set with each new instance.
$this->Smarty();
$this->template_dir = $Root."/templates";
$this->compile_dir = $Root."/templates_c";
$this->config_dir = $Root."/configs";
$this->cache_dir = $Root."/cache";
}
}
|
How do I access the value o $a and $b in my template's file
I've tried with $smarty.a but it doen't work
Ciao
Simone
Last edited by Hpatoio on Tue Jul 06, 2004 3:25 pm; edited 1 time in total |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Nov 07, 2003 9:39 am Post subject: |
|
|
hi simone.
the usual way, of course:
$smarty->assign('a', $smarty->a);
$smarty->assign('b', $smarty->b);
or perhaps
$local['a'] = $smarty->a;
$local['b'] = $smarty->b;
$smarty->assign('local', $local); // {$local.a} etc.
so, what are you really getting at |
|
Back to top |
|
Hpatoio Smarty Rookie
Joined: 29 Apr 2003 Posts: 25 Location: Italy
|
Posted: Fri Nov 07, 2003 9:49 am Post subject: |
|
|
boots wrote: |
the usual way, of course:
$smarty->assign('a', $smarty->a);
$smarty->assign('b', $smarty->b);
|
Ok, but I thought was possible to access directly my propriety in the .tpl file in a way like :
Code: |
<p>Some text : {$smarty.a} </p>
|
without assign it to another smarty variable.
Something like happen for {$smarty.session.myvar}
Don't you think should be possible to have this possibility
/Simone |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Nov 12, 2003 2:01 am Post subject: |
|
|
Hpatoio wrote: | without assign it to another smarty variable.
Something like happen for {$smarty.session.myvar}
Don't you think should be possible to have this possibility
|
Not really, no. Also, the $smarty in your template != $smarty in your php. Not even close. The $smarty VAR in your template is a special variable that is built automatically for you by Smarty. The $smarty OBJECT in your PHP is the whole bag of wax.
You can of course, assign objects to your template...but don't pass the smarty object into your template -- its just bad. Really, really bad. Better to create another custom object to hold your properties.
see: http://smarty.php.net/manual/en/advanced.features.php#ADVANCED.FEATURES.OBJECTS |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|