Re: [SMARTY] Re: call to class/method
| From: | Paul Lockaby | Date: | Sun, 15 Dec 2002 01:10:42 +0000 |
| Subject: | Re: [SMARTY] Re: call to class/method | ||
| References: | 1 2 3 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6801@lists.php.net to get a copy of this message | ||
Akorthaus@Web.De wrote:
Hallo! [sorry, I forgot to answer to the list ;-), but I also added some contend]Ah, you might try this. Call the insert function and then inside the insert function you either reference a preexisting class or create a new one and work with it. I don't think it's possible to call a class directly from a template, but using insert you can call a function that loads the class, works with the class and then returns the results. I know that you're trying to make everything modular, but I really don't think it's possible to do that. Perhaps someone else can suggest a way to make a plugin or something that would achieve what you want to do. Personally, what I've described is how I would do it. I hope this helps :-\ Regards, PaulThe other way is to use {insert} and then, from the insert function, return the data you gathered from the other function you wanted to call. This way you can keep your designers from seeing any PHP and having too much access to code and whatnot.But this way I only can use a functions. What I want to do is use a method of a class. {insert} works like that: {insert name="getBanner" lid=#banner_location_id# sid=#site_id#} will do that: insert_getBanner(array("lid" => "12345","sid" => "67890")); What I need is: $my_class -> insert_getBanner(); Or can I somehow build an own plugin for smarty which behaves like that? Something like: {insert_from_class method="getBanner"} $insert_from_class -> getBanner(); I want to do this, because I´m working on a completly modul-based PHP-project. The differnt modules have two files, one file only with a php-class, and one template-file. The main-modul loads the class and the template, and the template should only use PHP inside the own modul-class. Thank you very much! regards Andreas