General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 16th, 2002, 05:04 PM
Lasse Lasse is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 14 Lasse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 29 sec
Reputation Power: 0
Question patTemplate vs Smarty?

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?

Reply With Quote
  #2  
Old September 16th, 2002, 09:07 PM
ejbe99 ejbe99 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 43 ejbe99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 40 sec
Reputation Power: 17
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.

Reply With Quote
  #3  
Old September 17th, 2002, 02:07 PM
water water is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 10 water User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by ejbe99
First off, I still don't get why people would use a large class for a template. include(), anyone?


then you should find that this dicussion, http://www.sitepointforums.com/show...&threadid=67849 is quite interesting

:water

Reply With Quote
  #4  
Old September 17th, 2002, 03:11 PM
ejbe99 ejbe99 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 43 ejbe99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 40 sec
Reputation Power: 17
Quote:
Originally posted by water


then you should find that this dicussion, http://www.sitepointforums.com/show...&threadid=67849 is quite interesting

:water

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!

Reply With Quote
  #5  
Old September 17th, 2002, 03:48 PM
Lasse Lasse is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 14 Lasse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 29 sec
Reputation Power: 0
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!

Reply With Quote
  #6  
Old September 17th, 2002, 04:22 PM
ejbe99 ejbe99 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 43 ejbe99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 40 sec
Reputation Power: 17
Quote:
Originally posted by Lasse
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!

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()

Reply With Quote
  #7  
Old September 17th, 2002, 04:47 PM
Lasse Lasse is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 14 Lasse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 29 sec
Reputation Power: 0
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?

Reply With Quote
  #8  
Old September 17th, 2002, 05:21 PM
ejbe99 ejbe99 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 43 ejbe99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 40 sec
Reputation Power: 17
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:
 $title "Hello, this is my very first page!";
$maintext "And we don't even have to use a useless template 'engine'!";
$footer "Copyright 2002-2004 YourCompany. All rights reserved.";

include(
"template.tpl"); 

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.

Reply With Quote
  #9  
Old September 17th, 2002, 05:37 PM
Lasse Lasse is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 14 Lasse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 29 sec
Reputation Power: 0
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

Reply With Quote
  #10  
Old September 17th, 2002, 05:42 PM
ejbe99 ejbe99 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 43 ejbe99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 40 sec
Reputation Power: 17
Quote:
Originally posted by Lasse
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

No problem

Now spread the word to everyone you know who uses Smarty!

Reply With Quote
  #11  
Old September 17th, 2002, 07:02 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #12  
Old September 17th, 2002, 08:48 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 18
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
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

Reply With Quote
  #13  
Old September 17th, 2002, 09:26 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #14  
Old April 14th, 2003, 11:25 AM
torrent torrent is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 19 torrent User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #15  
Old April 14th, 2003, 06:22 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 16
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

Reply With Quote
  #16  
Old April 15th, 2003, 05:21 AM
hadley hadley is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 63 hadley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
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

Reply With Quote
  #17  
Old April 15th, 2003, 07:25 AM
torrent torrent is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 19 torrent User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #18  
Old April 15th, 2003, 04:12 PM
hadley hadley is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 63 hadley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
The major problem I have with using templating engines is that they're never powerful enough for me.

I have tried using them in the past but it seems that I have to create heaps of template variables and add a lot of logic to the templates to get the control I need. I find it a lot easier to do all this inside php itself, where I have access to its full power, rather than a small subset.

I do, however, keep a strict division between my presentation and "business" code, and many of my presentation classes (views) work equally well on whatever model object I feed them.

That said, I've never worked in a situation where I've designed the code and someone else has done the graphic design. I'm sure in that situation I'd probably lean more towards a templating engine.

Hadley

Reply With Quote
  #19  
Old April 16th, 2003, 12:36 AM
torrent torrent is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 19 torrent User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I totally agree with your sentiment that templates don't suit every application. No doubt about that. For example, I never use templates when I am writing something for myself. After all, why should I care if the presentation and application code are separated or not? Like you rightly summise though, in instances where you are supplying something to a customer or a graphic designer, and they may have then need to modify the presentation (integrate it with their existing design or something) then templates are really useful.

It's horses for courses as they say. At the end of the day I don't say everyone should use templates as usually there is no need, however, I will disagree with those who say they are never needed and that include() performs the same functionality.


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > patTemplate vs Smarty?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap