Is there any good tutorial on PHP & TPL files?
I can't understand well how TPL (template) files work with PHP, like ones on www.phpbb.com. I would appreciate if you could give some links to good tuturials. Thanx
Public Comments
- You can find really gud tutorials about many languages (web desinging ) especially at http://www.w3schools.com
- This is the good place to start. enjoy
- it uses template engine system similar to smarty template engine. basically the idea is creating a tag and replacing those tags with the defined content while parsing the template. here's a sample code to give you an idea on how it works. lets say you have a template.tpl as your template file with 2 tags: <html> {content1} <br>{content2} </html> now you have your php file to parse this template and diplay the values for the tags we've declared. <?php // sample values $content1="hello world!"; $content2="hi there!"; // declare it in a array so that you can loop it later during parsing $array=array( 'content1' => $content1 'content2' => $content2 ) // parse template file into string $template=file_get_contents("template.tpl"); foreach ($array as $var => $array) // Loop the array. { $data=str_replace("{".$var."}", $array, $template); } // End of loop // now diplay the page eval('?>'.$data.''); ?>
Powered by Yahoo! Answers