Smarty Templates from Database

Smarty Templates from Database

am 17.01.2008 12:01:21 von brunormbarros

Smarty, on the readme, says it is able to get template from arbitrary
sources, file system or database. I have seen $default_resource_type
and it can be file: or db:...

After searching the documentation, I found:

http://www.smarty.net/manual/en/template.resources.php

But then, where is it cached and compiled? Is there a way to run
Smarty 100% from the database?

Re: Smarty Templates from Database

am 17.01.2008 14:49:46 von pritaeas

"Bruno Rafael Moreira de Barros" wrote in message
news:1d4f374d-5e28-415c-b2d2-2a6a1ede3dd2@l1g2000hsa.googleg roups.com...
> Smarty, on the readme, says it is able to get template from arbitrary
> sources, file system or database. I have seen $default_resource_type
> and it can be file: or db:...
>
> After searching the documentation, I found:
>
> http://www.smarty.net/manual/en/template.resources.php
>
> But then, where is it cached and compiled? Is there a way to run
> Smarty 100% from the database?

If you also want to cache to the database:
http://www.smarty.net/manual/en/section.template.cache.handl er.func.php

Re: Smarty Templates from Database

am 18.01.2008 13:11:49 von brunormbarros

On Jan 17, 1:49 pm, "pritaeas" wrote:
> "Bruno Rafael Moreira de Barros" wrote in messagenews:1d4f374d-5e28-415c-b2d2-2a6a1ede3dd2@l1g2000hsa. googlegroups.com...
>
> > Smarty, on the readme, says it is able to get template from arbitrary
> > sources, file system or database. I have seen $default_resource_type
> > and it can be file: or db:...
>
> > After searching the documentation, I found:
>
> >http://www.smarty.net/manual/en/template.resources.php
>
> > But then, where is it cached and compiled? Is there a way to run
> > Smarty 100% from the database?
>
> If you also want to cache to the database:http://www.smarty.net/manual/en/section.template.ca che.handler.func.php

What about the compiled TPL files?

Re: Smarty Templates from Database

am 21.01.2008 09:32:24 von pritaeas

"Bruno Rafael Moreira de Barros" wrote in message
news:d5e6ed5f-5147-41d3-abfc-0ff7b0c184d3@e25g2000prg.google groups.com...
> On Jan 17, 1:49 pm, "pritaeas" wrote:
>> "Bruno Rafael Moreira de Barros" wrote in
>> messagenews:1d4f374d-5e28-415c-b2d2-2a6a1ede3dd2@l1g2000hsa. googlegroups.com...
>>
>> > Smarty, on the readme, says it is able to get template from arbitrary
>> > sources, file system or database. I have seen $default_resource_type
>> > and it can be file: or db:...
>>
>> > After searching the documentation, I found:
>>
>> >http://www.smarty.net/manual/en/template.resources.php
>>
>> > But then, where is it cached and compiled? Is there a way to run
>> > Smarty 100% from the database?
>>
>> If you also want to cache to the
>> database:http://www.smarty.net/manual/en/section.template.ca che.handler.func.php
>
> What about the compiled TPL files?

Found this:

Q: Can I force Smarty to store compiled templates into database rather than
file on the disk?
A: Not yet... But perhaps you could find someone to implement it ;)

A: You shouldn't, it will be a great performance disadvantage, because PHP
cannot execute them directly from database.

A: Technically, you can use PHP's recently added streams API to implement
your storage type at the PHP level. This would enable PHP to include your
code just as if it was a local file; unfortunately, this isn't trivial to
implement and would likely require some customizations to Smarty as well.

A: Ugly hack, but I guess it works for sending the compiled code to a
string:

function compile_to_string(&$smarty, $filename) {

$_params = array('resource_name' => $filename);

$smarty->_fetch_resource_info($_params);

$smarty->_compile_source($filename, $_params['source_content'],
$compiled_content);

return($compiled_content);
}
Here:http://66.102.9.104/search?q=cache:WnhTq3VcvYwJ:smarty. incutio.com/%3Fpage%3DSmartyFrequentlyAskedQuestions+smarty+ compiled+tpl+database&hl=en&ct=clnk&cd=2

Re: Smarty Templates from Database

am 28.01.2008 11:03:57 von brunormbarros

On Jan 21, 8:32 am, "pritaeas" wrote:
> "Bruno Rafael Moreira de Barros" wrote in messagenews:d5e6ed5f-5147-41d3-abfc-0ff7b0c184d3@e25g2000prg .googlegroups.com...
>
>
>
> > On Jan 17, 1:49 pm, "pritaeas" wrote:
> >> "Bruno Rafael Moreira de Barros" wrote in
> >> messagenews:1d4f374d-5e28-415c-b2d2-2a6a1ede3dd2@l1g2000hsa. googlegroups.com...
>
> >> > Smarty, on the readme, says it is able to get template from arbitrary
> >> > sources, file system or database. I have seen $default_resource_type
> >> > and it can be file: or db:...
>
> >> > After searching the documentation, I found:
>
> >> >http://www.smarty.net/manual/en/template.resources.php
>
> >> > But then, where is it cached and compiled? Is there a way to run
> >> > Smarty 100% from the database?
>
> >> If you also want to cache to the
> >> database:http://www.smarty.net/manual/en/section.template.ca che.handler.func.php
>
> > What about the compiled TPL files?
>
> Found this:
>
> Q: Can I force Smarty to store compiled templates into database rather than
> file on the disk?
> A: Not yet... But perhaps you could find someone to implement it ;)
>
> A: You shouldn't, it will be a great performance disadvantage, because PHP
> cannot execute them directly from database.
>
> A: Technically, you can use PHP's recently added streams API to implement
> your storage type at the PHP level. This would enable PHP to include your
> code just as if it was a local file; unfortunately, this isn't trivial to
> implement and would likely require some customizations to Smarty as well.
>
> A: Ugly hack, but I guess it works for sending the compiled code to a
> string:
>
> function compile_to_string(&$smarty, $filename) {
>
> $_params = array('resource_name' => $filename);
>
> $smarty->_fetch_resource_info($_params);
>
> $smarty->_compile_source($filename, $_params['source_content'],
> $compiled_content);
>
> return($compiled_content);}
>
> Here:http://66.102.9.104/search?q=cache:WnhTq3VcvYwJ:smarty. incutio.com/%3...

Yeah I have noticed it is extremely hard, and it's useless. Imagine
the images, that are not required by PHP, but are required by the
client, using HTML. They would be on the database... I'm using Smarty
in normal directories now...