Welcome to our forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Forum Statistics

  • Forum Members:
  • Total Threads:
  • Total Posts: 3
There are 1 users currently browsing forums.
PHP Scripting PHP is a scripting language for rapid web-development. It's a popular and powerful, OOP-capable language that is used by professionals. Discuss PHP here.

Reply
  #1  
Old 11-22-2009
vento's Avatar
Sexy monkey
 
Join Date: May 2009
Location: Lithuania
Age: 16
Posts: 185
Rep Power: 1
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 shitload 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
  #2  
Old 11-22-2009
Toddler
 
Join Date: Nov 2007
Posts: 27
Rep Power: 0
juddster is on a distinguished road
Re: Template script

Someone I know from another forum made one and it seems pretty good. Though I haven't really used it for a *lot* of websites ... nor actually looked in the code.

It may be worth looking at though. The link is:
Yasu's Development Blog

~juddster
Reply With Quote
  #3  
Old 11-23-2009
vento's Avatar
Sexy monkey
 
Join Date: May 2009
Location: Lithuania
Age: 16
Posts: 185
Rep Power: 1
vento is on a distinguished road
Re: Template script

As I understood from code that guy showed, it also uses replace to fill variables like {user.name} to whatever you give to the class function. I really don't like the idea that I gonna have to replace something as it requires a long string to replace the main, content, part of the website.

Damn, looks like every single engine uses replacing feature. That looks so weird... I have to read more about that 'caching' I haven't read anything about such feature in PHP for template.
Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Class Template in Visual C++ yalcin C and C++ Programming 1 07-26-2009 07:46 PM
I need my template coded & script installed Mr19 General Web Programming 1 05-26-2009 05:51 AM
Tutorial: Create a simple login script using ASP.NET bfsog .Net Programming 0 09-24-2008 05:07 AM
New Version of HTB Monitoring Script Introduces System Tray Add-on hostthebest News and Discussion 0 06-03-2008 07:00 AM
PEAR's HTML_Template_IT package. wizard HTML & CSS Articles 1 11-19-2005 01:27 AM