Re: snapshot : default template handler
| From: | Ralph Meijer | Date: | Mon, 10 Dec 2001 22:38:49 +0000 |
| Subject: | Re: snapshot : default template handler | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2245@lists.php.net to get a copy of this message | ||
Hi!
This is a good step, but I would take it one bit further. As I mentioned
before: let there be a function that has the complete resource identifier
(as given in a {include} or a fetch()/display()) as argument and return
another.
This has the same (minimal) overhead as this new function, but you can
accomplish more. The implementation of the function you created here
as an example would be that it returns the unmodified resource if the
template file exists, and e.g. the name of a default template if it doesn't.
My EUR 0.02,
Ralphm
On Mon, Dec 10, 2001 at 12:16:48PM -0600, Monte Ohrt wrote:
> I added a default template handler (currently only works for local
> files) and updated the snapshot.
>
> usage:
>
> var $default_template_handler_func = 'my_tpl_func'; // set to your
> default template handling function
>
>
>
> // in your application
>
> function my_tpl_func ($resource_type, $resource_name) {
> if(!@touch($resource_name))
> return false;
> return true;
> }
>
>
>
>
>
> The template handling function is expected to take the resource type and
> resource name as arguments, and return true or false for success or
> failure.
>
> In my example, it attempts to create the a blank template.
>
> Let me know what you think, bugs, if arguments look good, etc.
>
>
> Monte
>
> ---
> You are currently subscribed to smarty as: smarty@ralphm.ik.nu
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at 0wÑÉÀi5Or4™²Ÿ
> http://www.phpinsider.com/php/code/Smarty/
--
Groetjes, ,-----------------------------------------------------.
| ,.. en nou moet ik ophangen, d'r komt een bocht aan. |
Ralphm `------------------------------------------------------'