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

{insert}-php-function should be a "true" callback

 
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 -> Feature Requests
View previous topic :: View next topic  
Author Message
Warhog
Smarty n00b


Joined: 12 Dec 2005
Posts: 3
Location: Bocholt, NRW, Germany

PostPosted: Mon Dec 12, 2005 9:52 pm    Post subject: {insert}-php-function should be a "true" callback Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Dec 12, 2005 10:03 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Warhog
Smarty n00b


Joined: 12 Dec 2005
Posts: 3
Location: Bocholt, NRW, Germany

PostPosted: Mon Dec 12, 2005 10:12 pm    Post subject: Reply with quote

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 Smile

I apologize for any inconveniences, however thanks a lot Smile
Back to top
View user's profile Send private message Visit poster's website AIM Address
messju
Administrator


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

PostPosted: Tue Dec 13, 2005 10:09 am    Post subject: Reply with quote

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. Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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 -> Feature Requests 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