Re: [SMARTY] Re: call to class/method

From: Date: Sun, 15 Dec 2002 01:19:27 +0000
Subject: Re: [SMARTY] Re: call to class/method
References: 1 2 3 4 5  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6804@lists.php.net to get a copy of this message
Akorthaus@Web.De wrote:
Hi!
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 hope that helps!
But this function has to be in my module php-Script, and there I only want to have the class. Perhaps I can rewrite the {INSERT}-Plugin of smarty, so I build in an own {INSERT2}, which is a copy of {INSERT}, only modified this way, that the Inside-Funktion translates the tmplate-Variable in another way: {insert name="getBanner"} will do: insert_getBanner(); {insert2 name="getBanner"} will do: $my_class -> insert_getBanner(); Or isn´t it that simpe as I think now? Regards Andreas
Seems like it should work. However, I am not sure how to code it. The {insert} function is internal to smarty and thus is not as easy as editing a plugin. I suppose a plugin could be written. You might give it a try. Paul

« previous php.smarty.general (#6804) next »