Page 1 of 1
Templates and Includes
Posted: Tue Jun 24, 2003 3:45 am
by Luftikus
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
Posted: Tue Jun 24, 2003 6:02 am
by releasedj
Good question!
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.
All of these arguments have valid arguments. The one you choose is probably down to your skill set and your time constraints.
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.
Posted: Tue Jun 24, 2003 6:15 am
by Luftikus
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
Posted: Tue Jun 24, 2003 6:30 am
by releasedj
I use a template class system, which parses a file and replaces certain tags.
Posted: Tue Jun 24, 2003 6:40 am
by Luftikus
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
Posted: Tue Jun 24, 2003 6:58 am
by releasedj
I use a template system that I wrote myself.. there are however plenty of template systems out there, here's a small list.
That's a good starting point. I'm sure others might post some more links.
Posted: Tue Jun 24, 2003 4:46 pm
by Sevengraff
I reccomend
Easy Template System.. It comes with a great manual and is amazingly easy. It has some good functions and stuff also.
Posted: Tue Jun 24, 2003 5:59 pm
by mikusan
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...
Posted: Tue Jun 24, 2003 6:13 pm
by nielsene
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
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;
Templates work great for some poeple. I'm just happier in code....
Posted: Tue Jun 24, 2003 8:25 pm
by McGruff
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.