Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

How do I access my properties ?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Hpatoio
Smarty Rookie


Joined: 29 Apr 2003
Posts: 25
Location: Italy

PostPosted: Thu Nov 06, 2003 8:38 pm    Post subject: How do I access my properties ? Reply with quote

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 Question

I've tried with $smarty.a but it doen't work Rolling Eyes

Ciao

Simone


Last edited by Hpatoio on Tue Jul 06, 2004 3:25 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Nov 07, 2003 9:39 am    Post subject: Reply with quote

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 Wink
Back to top
View user's profile Send private message
Hpatoio
Smarty Rookie


Joined: 29 Apr 2003
Posts: 25
Location: Italy

PostPosted: Fri Nov 07, 2003 9:49 am    Post subject: Reply with quote

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 Question

/Simone
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Nov 12, 2003 2:01 am    Post subject: Reply with quote

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 Question


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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP