Re: snapshot : default template handler
| From: | Monte Ohrt | Date: | Mon, 10 Dec 2001 23:04:27 +0000 |
| Subject: | Re: snapshot : default template handler | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2247@lists.php.net to get a copy of this message | ||
I think I see what you're saying now... maybe the custom function should
work a bit differently:
* Smarty looks for the template resource.
* If not found, it executes the custom function to get the template
resource.
* If still not found, then show the error.
In this case, the custom function is required to fetch the template
contents (and create a new template file, or whatever), as well as
return true/false.
That sounds like a good idea, is that what you were getting to?
Ralph Meijer wrote:
>
> 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
> > http://www.phpinsider.com/php/code/Smarty/
>
> --
> Groetjes, ,-----------------------------------------------------.
> | ,.. en nou moet ik ophangen, d'r komt een bocht aan. |
> Ralphm `------------------------------------------------------'
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/