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

get Value from class-methode from template

 
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
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Thu Apr 24, 2003 8:28 am    Post subject: get Value from class-methode from template Reply with quote

Hi!

How could I get the return-value of an class-methode? I hav got an object $user, and I have the methode checkRight()

In PHP I would do:

Code:
if($user->checkRight("displayFeature_XY")) {
    echo "blablabla";
}


How could I do this in a smarty-template?

regards
Andreas


Last edited by andreas on Wed May 05, 2010 10:33 pm; edited 1 time in total
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Apr 24, 2003 9:21 am    Post subject: Reply with quote

see:
http://smarty.php.net/manual/en/advanced.features.php#ADVANCED.FEATURES.OBJECTS

have fun
messju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Thu Apr 24, 2003 9:55 am    Post subject: Reply with quote

Thank you!

Could I do this global for each template? That I don't need to register my object in each php-script?

________
vaporizer instructions


Last edited by andreas on Fri Feb 04, 2011 8:59 am; edited 2 times in total
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Apr 24, 2003 10:18 am    Post subject: Reply with quote

the registered object is available in all templates during the runtime of the one php-request that registered the object.

you have to create a new object-instance on each request (=each click from the user) and you have to (re-)register the object to smarty on each request.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Thu Apr 24, 2003 10:40 am    Post subject: Reply with quote

What I wanted to say, I need this object in each PHP-requst, so I allways must assign it by

$smarty->register_object()

in each PHP-script. So I would like to assign it allways automatically.

________
Escape


Last edited by andreas on Fri Feb 04, 2011 8:59 am; edited 2 times in total
Back to top
View user's profile Send private message
boots
Administrator


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

PostPosted: Thu Apr 24, 2003 11:03 am    Post subject: Reply with quote

You could put it in your smarty wrapper:

Code:
class MySmarty extends Smarty {
function MySmarty()
    {
    parent::Smarty();
    $this->register_object(...);
    }
}


of course you would then use this class instead of the normal smarty class.

Code:
$smarty = new MySmarty;
Back to top
View user's profile Send private message
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Thu Apr 24, 2003 12:51 pm    Post subject: Reply with quote

Oh Wink

that should be the way, thank you!

________
Subaru FF-1 Star specifications
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