Categories > Your tips & tricks >

Reading template form a string

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Morten Grunnet Buhl
Date: 2006-01-05
Time: 13:41

Reading template form a string

I am working alot with databases when I create webpages. I really enjoy the natural way TBS fits into this only I was missing the feature wherefrom I could read a string into the template engine instead of a file. I made this ungly hack to get that ability:
...(deleted by admin, read after)...
By: Skrol29
Date: 2006-01-05
Time: 16:25

Re: Reading template form a string

Hello Morten,

I'm afraid there muche more simple :
$TBS->Source = $my_template_source;
By: Morten
Date: 2006-01-05
Time: 16:42

Re: Reading template from a string

Again I bow to you, and blush a bit for not noticing the obvious...
Sometimes its more easy to lift up the rock and look under it that to blow it to atoms with an overdoze of C4.
I guess that doesnt solve the TBS special fields template_name, template_date and template_path though?

Thanks Skrol29
By: Skrol29
Date: 2006-01-05
Time: 18:08

Re: Reading template from a string

> I guess that doesnt solve the TBS special fields template_name, template_date and template_path though?

That's true.
To load a template from a string and having automatic fields processed, here is the code:
$TBS->Source = $my_template_source;
$TBS->MergeSpecial('onload');