By: Niklas K.
Date: 2006-07-27
Time: 21:00
|
Execute php-code from templatesHello,
is there any chance to parse PHP Code which is in a template? I need it to code a CMS with PHP-in-page-Support. I don't want to include external files with the TBS-function for it or an iFrame... Greetings, Niklas K. |
||
By: TomH
Date: 2006-07-27
Time: 21:26
|
Re: Execute php-code from templatesNoit only is that easy -but- you can also cache those TBS/php code scripts separately.
Take a careful look at the TBS example page ref "Execute another script" for full details. The short of it is TBS PHP code
There is example of the caching of subscripts -and- a prototype TBS CMS at http://tomhenry.us/tbs3/ HTH |
||
By: Niklas K.
Date: 2006-07-27
Time: 21:36
|
Re: Execute php-code from templatesYes, I know this method, but I said I don't want to use it. It is because I don't want to write files.
|
||
By: TomH
Date: 2006-07-28
Time: 00:46
|
Re: Execute php-code from templatesThen it seems you are saying you want to do not templates -- as TBS templates contain not native PHP only TBS processing directives.
If you don't want to write files - you still need the PHP code to be somewhere - why not put the PHP in the main file that calls the templates? |
||
By: Niklas K.
Date: 2006-07-28
Time: 08:59
|
Re: Execute php-code from templatesI can't do that because I want to develop a CMS where you can install php code... must I switch to Smarty to make a system like this:
<html> ..... [var.content] ..... </html> $content gets its content from a MySQL-Row where the id is the $_GET['id']. And I have a row like this: pageid: 1 title: a simple php test name(that's for the menu): php... content: <?php echo 1+1; ?> I hope you understand me now. Can I use eval(); to do this? |
||
By: Skrol29
Date: 2006-07-28
Time: 11:20
|
Re: Execute php-code from templatesHello,
You could a use parameter "onformat" to apply a custom function on the content you want. This custom function could run the content as a php snippet using eval() and catch the result using ob_start() / ob_get_contents(). You need to catch the result in order to have it placed on the TBS tag instead of immediatly to client. |
||
By: jahbini
Date: 2006-08-14
Time: 21:35
|
Re: Execute php-code from templatesIn the bouwels of the TBS system resides the function that opens system files. It is blessedly small and seems to be the only gateway for opening a system file.
A simple addition to it will allow any 'filename' that begins with ']' (Technically that's a legal beginning char for a file name, but you won't find too many files beginning with it, so use at your own pleasure/peril) I'm putting this into my system for templates, since I'm working with a system where the templates would be pulled out of SQL and are not really in the files at all. Anyway here it is, and I hope it would be generally useful to the TBS community:
|