Thread: Template script
View Single Post
  #1  
Old 11-22-2009
vento's Avatar
vento vento is offline
Sexy monkey
 
Join Date: May 2009
Location: Lithuania
Age: 17
Posts: 185
Rep Power: 2
vento is on a distinguished road
Template script

Hello. So far I've been using a simple template method. It works like this: in index.php I set a few variables (title of page, content source etc) and include template.php. From template.php I use $content_src to include the source file (in this case I would use index_content.php). This is pretty comfortable and pretty fast, but even a small projects requires tons of files. (double than it is supposed to).

Another option I've found on the internet is to use a variable to write the whole content code into it and then use it to replace special tag (like {content} ) in the template file or just include a template.php at the end and then just simply use echo to print the whole code. I don't like this option because it is going to work slowly and take ****load of memory. I mean that string is going to be really long and that means a lot of memory wasted. In addition long string means a lot of data to take care of which results as a time waste (copying and writing to it time is going to be a "wasted time").

To sum up, I have no idea how to make an effective template system in PHP. Could you suggest any?

P.S. Maybe it's just my option that a long string is bad, IDK, but you're not going to change my mind about it.
__________________

How to set up portable C++ IDE (Dev-C++)

Writing in C or C++ is like running a chain saw with all the safety guards removed," — Bob Gray.
Reply With Quote