![]() |
PHP Template
Greetings! I am currently making a few projects, but I am very worried about how I should do my templating system so I do not at some point regret how I did it, and want to recode it!
Basically, I just want to insert informations into my sites easily but also, it shouldn't become a mess with shit loads of php calls inside the HTML. I could pretty easily do something like this: PHP Code:
Example: PHP Code:
PHP Code:
I hope I can get some help on doing this part properly. :) |
If you can't use PHP than use Smarty or PHPTal even if you say they're weird they're extremely useful and Smarty isn't that slow with File cahce and opcode code cacher installed.
|
I'm looking for a short introduction, or someone to point me in the right direction of using PHP in a good way for templating. Since I'll learn a lot more from that, than I will by just using Smarty or any of these other engines..
|
Well there are several ways to go about it and my preferred way is something to this effect..
php Code:
And the template file would look something like this php Code:
The actual class php Code:
|
Thanks a lot! :)
Would it be a bad habbit to use shortcuts here: PHP Code:
PHP Code:
|
Unless it's your server and your site, it is ALWAYS bad habit to use shortcuts.
|
I am also confused whether to use smarty or not,whether to use include/require functions or make a custom template class.
I have search many website there always pros and cons arguements about it. |
I made a rather simple "Framework" recently, as it's really good practise, this is my finished Template class if you'd like to see it.
It's faily simple to use, just browse the sample files. :) |
Line 69 :
php Code:
php Code:
ob_end_clean() will clean all buffers started with ob_start() .. any buffer started before parsing the template will be flushed, while ob_clean() will only empty the last buffer started. Cleaning the enter buffer could result in later bugs, if using output buffering for other sections |
Quote:
|
I have got a question regarding your custom made template.
if you assign in index.php. It doesn't parse included html files. Can you please tell me how to solove it ? Index.php |
| All times are GMT. The time now is 08:21 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0