Templates and Includes
Moderator: General Moderators
Templates and Includes
Hi list,
I hope that this is not off the topic here. But I was spending quite some while with the help of Google and Co to find some deeper insights into template-usage, like FastTemplate. Actually that was more or less the only response I found on the Net. Unfortunately it seemed a bit outdated, as many of the posts/pages/comments I found dated back almost to the last century...
So, I would like to ask if something like FastTemplate isn't used anymore, but instead for example includes and configs? Or more generally what is the way to program these days more complex and dynamic PHP/MySQL/HTML sites?
Best wishes and thanks for any help,
Stefan
I hope that this is not off the topic here. But I was spending quite some while with the help of Google and Co to find some deeper insights into template-usage, like FastTemplate. Actually that was more or less the only response I found on the Net. Unfortunately it seemed a bit outdated, as many of the posts/pages/comments I found dated back almost to the last century...
So, I would like to ask if something like FastTemplate isn't used anymore, but instead for example includes and configs? Or more generally what is the way to program these days more complex and dynamic PHP/MySQL/HTML sites?
Best wishes and thanks for any help,
Stefan
Good question!
This question always starts a 3-way-divide. The 3 sides are usually:
Personally, I think the XML/XSLT way is when you have an advanced skill set and time to spend setting it up. And if your content is going to be used in different forms of presentation then this is a good idea. However I think very few people have all these requirements.
Me, I tend to use templates where possible. Not because I think it's easier for the designers (I don't work with designers like that, it's usually me doing the HTML), but because it forces me to do some sort of seperation between my PHP and HTML, which in turn leaves me with much cleaner looking PHP pages.
Using templates does give you more overhead to deal with. Using PHP as the template engine does not bring this overhead, but then you have to force yourself to follow certain guidelines. These guidleines tend to get ignore a little if you're dealing with a fast approaching deadline.
The method you decide to use (if any of the above) should be down to what you feel comfortable with, and what your requirements are.
This question always starts a 3-way-divide. The 3 sides are usually:
- Those who use templates and argue that it's the best way to interact with designers.
- Those who say that PHP is itself the best template system out there, so all the others are useless.
- Those who say that we should be using PHP/XML/XSLT, as this is a standard.
Personally, I think the XML/XSLT way is when you have an advanced skill set and time to spend setting it up. And if your content is going to be used in different forms of presentation then this is a good idea. However I think very few people have all these requirements.
Me, I tend to use templates where possible. Not because I think it's easier for the designers (I don't work with designers like that, it's usually me doing the HTML), but because it forces me to do some sort of seperation between my PHP and HTML, which in turn leaves me with much cleaner looking PHP pages.
Using templates does give you more overhead to deal with. Using PHP as the template engine does not bring this overhead, but then you have to force yourself to follow certain guidelines. These guidleines tend to get ignore a little if you're dealing with a fast approaching deadline.
The method you decide to use (if any of the above) should be down to what you feel comfortable with, and what your requirements are.
Ok, I can see that. And my searches on the Net went into this direction.
When you are speaking of yourself using templates where possible: What kind of templates do you set up? Is it someting similar to FastTemplate or are you creating a bunch of (global) variables which hold the dynamic content before inserting them into the HTML code?
L.kus
When you are speaking of yourself using templates where possible: What kind of templates do you set up? Is it someting similar to FastTemplate or are you creating a bunch of (global) variables which hold the dynamic content before inserting them into the HTML code?
L.kus
Hmmm... I hope with the Newbie-credit I have, I am allowed to ask you what kind of "template class system" you are using, i.e. is it a package one finds on the Net or is it something you have developed on your own?
I am asking as well because I am still left "alone" with the question if this FastTemplate tool is worth considering? Or if there are other sources?
Thanks anyway for your input.
L.kus
I am asking as well because I am still left "alone" with the question if this FastTemplate tool is worth considering? Or if there are other sources?
Thanks anyway for your input.
L.kus
I use a template system that I wrote myself.. there are however plenty of template systems out there, here's a small list.
- smarty http://smarty.php.net/ NB: quite complicated for a beginner
- FastTemplate http://www.thewebmasters.net/
- PatTemplate http://www.php-tools.de/site.php
- Phemplate http://pukomuko.esu.lt/phemplate/
- Xipe http://opensource.visionp.biz/index.php?id=73
- TemplateTamer http://www.templatetamer.com/
- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact:
I reccomend Easy Template System.. It comes with a great manual and is amazingly easy. It has some good functions and stuff also.
I am going to back up releasedj, as i prefer to use templates myself, most of my site is templated the rest PHP can deal with, it keeps your code clean, more readable and personally easier to change/modify. It's really easy to make a tamplate system, i am just perfecting my skills with object oriented programming so i have yet to write a useable class... but my template parser is a function that does the easiest on earth, loads a *.thtml file which is just a name i gave it... and then replaces {tags} of this sort with proper stuff, that can be other html, or plain text or whatever you can fit... it has worked miracles... simple and effective...
I'm on of the "pure PHP" people. I have a "UIBase" class that abstracts most interface elements and then subclass "HTMLDisplay", "WMLDisplay" as appropriate. My viewable pages end up looking like
Templates work great for some poeple. I'm just happier in code....
Code: Select all
$display= new HTMLDisplay();
$page = $display->startPage("Page Title");
$page.= $display->instructionBox("Instructions...... ....");
$form = $display->addTextElement("VarName",$_POST["varValue"],
$var_msg, $var_label);
....
$page .= $display->wrapForm($form,"POST", "next.php");
$page .= $display->endPage();
echo $page;You can of course use html templates without doing any parsing - my own method.
Include a html file in the php script then, in the template, jump into <?php to echo a var. No parsing required.
Template engines usually add some custom Loop and IF/ELSE tags which, to my mind, blurs the clean separation of logic and output which one is looking for.
See the advanced forum for a discussion just getting started about template engines.
Include a html file in the php script then, in the template, jump into <?php to echo a var. No parsing required.
Template engines usually add some custom Loop and IF/ELSE tags which, to my mind, blurs the clean separation of logic and output which one is looking for.
See the advanced forum for a discussion just getting started about template engines.