|
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 |
Warhog Smarty n00b
Joined: 12 Dec 2005 Posts: 3 Location: Bocholt, NRW, Germany
|
Posted: Mon Dec 12, 2005 9:52 pm Post subject: {insert}-php-function should be a "true" callback |
|
|
I'm using PHP5 and i really like the new OOP-functionalities.. therefore, most of the applications i build are written as classes/objects/... . Each time I have to use the {insert}-function, i wish, the function given by the name-argument could be a callback-handler as described in the PHP-Documentation: http://de2.php.net/manual/en/language.pseudo-types.php
Maybe we could pass a callback via assign (or a new function assign callback, maybe Code: | $smarty->assign_callback('myfunction', array($obj, 'functionx')) | so that in the template we can use:
Code: | {insert name="myfunction"} |
It would help me quite a lot.
Another feature which has to to with the {insert}-function is.. caching is never done for it, but in some cases it would be usefull to have caching enabled - also for {insert}s - maybe as a new parameter?
e.g.: Code: | {insert name="myfunction" caching="yes"} |
where the default for caching is no (false).
so far
greetz, Warhog |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Dec 12, 2005 10:03 pm Post subject: |
|
|
Have you looked at block functions? They can use class methods, and they can be cached/non-cached.
As for insert functions, they are always non-cached. Use a normal template function (which can be a class method) for cachable content. |
|
Back to top |
|
Warhog Smarty n00b
Joined: 12 Dec 2005 Posts: 3 Location: Bocholt, NRW, Germany
|
Posted: Mon Dec 12, 2005 10:12 pm Post subject: |
|
|
aah! thanx a lot, that helps me quite well.. i just browsed throught the manual and didnt read the descriptions properly, as i thought that the possibility of handling a callback would be designated so.
than there is only one thing i'd suggest: (@ http://smarty.php.net/manual/de/api.register.block.php ) - change
Code: | void register_block ( string name, mixed impl, bool cacheable, mixed cache_attrs) |
to
Code: | void register_block ( string name, callback impl, bool cacheable, mixed cache_attrs) |
i think that would help a lot of people who are fit in PHP and are looking (maybe too fast) for answers
I apologize for any inconveniences, however thanks a lot |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Dec 13, 2005 10:09 am Post subject: |
|
|
good idea since the php manual does also use "callback". i think it didn't use "callback" when I wrote the prototypes for register_block() in the manual. I'll update that. |
|
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
|