|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
I'm about to choose a template system.
The choice is between patTemplates and Smarty. Is there anyone who knows advantages/disadvantages with those systems? |
|
#2
|
|||
|
|||
|
First off, I still don't get why people would use a large class for a template. include(), anyone?
Anyway, check out this benchmarking test. It doesn't include patTemplate, but it shows a bunch of others compared to smarty. |
|
#3
|
|||
|
|||
|
Quote:
then you should find that this dicussion, http://www.sitepointforums.com/show...&threadid=67849 is quite interesting :water |
|
#4
|
|||
|
|||
|
Quote:
Heh, I read that thread when it was still active. To fully understand the uselessness of a PHP template "engine", imagine that you create an "PHP HTML Engine". Instead of clients having to write HTML, they use your friendly PHPHTML language. {h2} = <h2> {form(name|somename)} = <form name="somename"> Wow, isn't that amazing! What an engine! ![]() |
|
#5
|
|||
|
|||
|
Ok, your point is: f*** templates.
But you still haven't answered my question. Instead of useless replies, write an article, "The uselessness of a PHP template", and publish it here at Devarticles! |
|
#6
|
|||
|
|||
|
Quote:
Hehe, well, I guess I could. But right now, I'm working on something else ![]() Anyway, no, my point is certainly not "f*** templates"! I think templates are very useful. Just not template "engines". Edit: Oh yeah, your question. I'd go with include() |
|
#7
|
|||
|
|||
|
Aha, template engines are useless. Now I get the point! Sorry!
You are saying "include('the_template')". Right? Then you use php variables in the templates instead of {nn}=<nn>? Have I got it? |
|
#8
|
|||
|
|||
|
Err, I think I may have confused you. This is how you make your own template "engine" with plain, easy, fast code.
Let's say you have a template, template.tpl: Code:
<html> <head> <title><?=$title?></title> </head> <body> <div align="center"><?=$title?></div> <?=$maintext?><br /><br /> <?=$footer?> </body> </html> Then you have your page that utilizes the template, template.php: PHP Code:
I don't know how smarty does it, but I think that's pretty simple. All your designers have to learn to do is use the <?=$variablename?> instead of {variable} syntax. Now, you could improve on this method. Perhaps you could make it easier on yourself by creating a script that allows you to select which template you're using, shows you what variables you need and lets you fill out their values, and then generates the appropriate code. |
|
#9
|
|||
|
|||
|
No, you didn't confuse me. I was trying to say that but obviously I failed...
But I did get it at last! Thank you ![]() |
|
#10
|
|||
|
|||
|
Quote:
No problem ![]() Now spread the word to everyone you know who uses Smarty! |
|
#11
|
|||
|
|||
|
i would prefer not to use templates, but reciently i had no choice,
i just made my own template class and it did the trick, all of these template engines claim to be fast, but then again, they have extra functions which arnt really needed |
|
#12
|
|||
|
|||
|
Although I could have created my own Template engine, I decided to go with patTemplate. Why re-invent the wheel (as they all say)?
Anyways, although I don't use ALL the features of patTemplate, I find the features that I use to be exceptional! I have found that the time spent on development is much faster than developing without a template system. The point of the template engine is to separate CODE from DESIGN... These seem to do just that, and they do it damn well! ![]() Anyways, if you're interested in learning a template system, and want one that is fairly easy, check out patTemplates... Also, check out Havard's tutorial (read it myself to get started).
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#13
|
|||
|
|||
|
hmm, just one more note, only use templates if you really have to, they are slower the a normal include. devArticles simply uses a top and bottom template, which is included on every file. Its simple, effective, and does the job
|
|
#14
|
|||
|
|||
|
Looks like I am resurrecting this thread from the dead but I have to point out that there is a world of difference between using include() over a template engine.
Templates engines are around because they enforce a methodology that most serious designers should embrace, and that's the Model-View-Controller methodology (MVC). This is one of the major benefits of JSP over PHP. It forces the developers to separate content from the business rules (or code in rudimentary terms). This is not the same as using include although similarities can be drawn. For more information on Model View Controller take a look here (they are not particularly PHP oriented): http://www.enode.com/x/markup/tutorial/mvc.html http://ootips.org/mvc-pattern.html or simply enter the search terms Model View Controller into Google. |
|
#15
|
|||
|
|||
|
I know a lot of people use for or while loops to output html content,.....how the heck do you do this with a template system?
__________________
-- Jason |
|
#16
|
|||
|
|||
|
If you're interested in reading more about the Model-View-Controller design pattern, PHP Patterns has a fairly good PHP based article: http://www.phppatterns.com/index.ph...cleview/19/1/1/
There is also a fairly reasoned argument about why templating in PHP is unnecessary: http://www.phppatterns.com/index.ph...icleview/4/1/1/ MVC != (necessary) using a templating system. Hadley |
|
#17
|
|||
|
|||
|
I read the reasoned article you placed a link to. While I can understand and even agree somewhat with some of his comments, others demonstrate a lack of understanding of the template design concept and revolve almost solely around the Smarty template (which I don't like one little bit). I can't help but feel that in a number of places he just doesn't grasp what templating is about.
My two main areas of disagreement lie with his view that template engines do not separate code from content. Of course they do. I am not saying that in the template you don't occasionally have a template engine decision block, but if you screw that decision block up it will only affect the output to the browser and NOT the application functionality itself. This is the idea behind separating model and control from the view. The customer is responsible for the presentation, you just ensure all the business rules are adhered to. You can also protect your code, the customer cannot make changes to it without coming through you again. This affords some protection of your IPR (Intellectual Property Rights). The second area is that he talks about the template engines having their own decision tag as a bad thing. I fail to see how this is any worse or more cumbersome than having PHP decision blocks, except that it is a lot easier to read than embedded PHP. Especially for those who are not programmers. Again, the poor examples he gives are from Smarty, which is not a good template engine. PatTemplate is much better as it uses XML type tags and is fully XHTML compliant. However, as always, it's good to see another side of the coin and he does have some valid points too. |
|
#18
|
|||
|
|||
|
The major proble |