|
Posted by boots on 09/09/05 02:47
--- Marcus Bointon <marcus@synchromedia.co.uk> wrote:
> On 9 Sep 2005, at 00:05, boots wrote:
>
> > Are you not using a custom resource to retrieve the templates from
> > the db?
> >
> > http://smarty.php.net/manual/en/plugins.resources.php
>
> Erm, no. At present I have this function in a Smarty subclass:
>
> //Function takes a template in a string and compiles it through
>
> Smarty
> public function compile_string_template($templatestring) {
> if($templatestring == '') {
> return '';
> }
>
> $this->_compile_source('string template', $templatestring,
> $source); //Source is passed by reference to be filled in
> //Dump compiled version in output buffer
> ob_start();
> eval('?>' . $source);
> $evaled = ob_get_contents();
> ob_end_clean();
> return $evaled;
> }
>
> Obviously inefficient, but functional - this code was from a smarty-
> general posting a couple of years ago when I originally asked about
> this!
Looks familiar...
> Now I look at it again, the resource plugin looks promising.
>
> > I tend to store my templates along with the features in the
> resource
> > that are required: a name (as a path), the template source, a
> > timestamp
> > (usually via an automatically updated timestamp column) and the
> > security level.
>
> As I recall when I was setting this up originally - the problem is
> the path - there is no path!
No path? How do you retrieve your templates? No matter -- you don't
literally need to store a path and further, the "path" needn't even
look like a file path -- you can parse out the name passed to the
resource anyway you see fit and from that develop a query to match your
db backend.
> > Don't forget that if you are using MySQL then you ought
> > use the MySql functions to convert to unix timestamps in your db
> > query.
>
> I don't use timestamps anywhere now - always ISO datetimes
> (especially now that MySQL 4.1 uses them everywhere), but as you say,
> conversion is not a problem. MySQL's SQL cache is my friend ;^)
>
> > Doing this, Smarty will be able to treat your foreign templates as
> if
> > they were local and will do all the right things in terms of
> > re-compiling on an as-needed-basis.
>
> I think my question is possibly simpler (and dumber!) - when a
> template is in a string and the compiled results are too, where do
> compiled versions get cached? Still in a local templates_c folder?
> back in the DB? in RAM? Is that decision controllable from a plugin
> too?
No -- Smarty exclusively uses the filesystem for compiled templates
(and cached template views). As Joe pointed out, you can put those on
an NFS volume if you want them shared.
It sounds like you might need to rethink some of your implementation
but I think the benefits would make it worth your while.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Navigation:
[Reply to this message]
|