|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
illusion Smarty n00b
Joined: 02 Nov 2003 Posts: 2
|
Posted: Sun Nov 02, 2003 5:19 am Post subject: Why Smarty? |
|
|
I am a newbie to the Smarty template engine, mucked around with it a little and from reading all these things said about smarty template. I have raised a question that I can't seem to find an answer.
Instead of using smary templates, we can do it by having a templates with variables. Then include that template in which ever page you want and have the business logics and variable values assigned before the inclusion. Cos smarty templates acts the same way (it seems). Maintenability level is just the same.
I am not talking about all the nice features (caching, partly compiled page etc) that it has, I am talking about the way of doing things with templates. Why add an extra layer?? All the features it has could be done as tool libraries.
Of course one of the reason I see is that designers are not prorammers, smarty can make things easier for them by making the syntax hidden (ie, {$var} instead of <?= $var ?> altho I don't really see how much easier), but why learn a whole new syntax instead of basic PHP? I am very curious. I am about to recommend my team to use Smartly templates at work. I would appreciate anyone could help me understand more about this. Thanks for reading/responding! |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sun Nov 02, 2003 6:07 am Post subject: |
|
|
Hi illusion. You seem to be talking about the very thing discussed in this thread. |
|
Back to top |
|
mniskanen Smarty Rookie
Joined: 26 Apr 2003 Posts: 20 Location: Lieksa,Finland
|
Posted: Wed Nov 05, 2003 12:18 pm Post subject: Re: Why Smarty? |
|
|
illusion wrote: |
Instead of using smary templates, we can do it by having a templates with variables.
|
That is just fine with simple, trivial applications.
illusion wrote: |
All the features it has could be done as tool libraries.
|
I did my best to find out a set of libraries some 18 months ago and after finding Smarty I have been searching for an even better alternative but found nothing yet. My designer can write PHP but his way of coding things is not on the professional level and I do not like the changes he might do in my OOP code.
One of the hardest things for us programmers to understand is the need to abstract the "rat's nest" code to a comprehensible level and this is what Smarty is good at. I have had a look at a dozen of frameworks, even bought one for $4500 just to find out that the lack of proper abstraction level leads to a very low level of maintainability. I have got mad and my designer has got mad.
Another thing one should remember is the overall flexibility. You can have a Smarty template that includes other templates. The various templates in the application can be output by a set of different Smarty instances and even by specialized Smarty-derived subclass instances. My recommendation is: learn OOP and use it!
In my multi-user db applications I am using a set of true OO classes that perform a multitude of actions using a relatively complex set of templates. The result is that I can write a multi-user db application that updates a couple of tables editing just a few lines of code. The logic in the Smarty "language" is very easy to learn and highly productive.
I use Smarty in all but the most trivial tasks, which may be 20-PHP-line dumps of a database or something alike.
Our work flow goes something like this:
- I study the customer's needs and design the application engine including the database etc.
- I create an ugly skeleton for the application using my humble skills
- I create a working prototype with the ugly version
- My designer has a look at the templates, disgusted, and rewrites them, mumbling...
- We deliver the prototype to our customer
After this I make the necessary changes to the code and sometimes to the template as well. If the look of the application has changed or needs to be changed I ask my designer to have a look at it.
The best thing is that our work is almost completely separate.
Markku |
|
Back to top |
|
illusion Smarty n00b
Joined: 02 Nov 2003 Posts: 2
|
Posted: Thu Nov 06, 2003 11:01 am Post subject: |
|
|
I am curious, why did you spend $4500 for some framework? Is separating the presentation from the business logic really that complicated for your applications? If you haven't, have a read on the J2EE pattern. I think it is great that made me think I don't need a template engine. It is all about how you design your application.
I still don't see how injecting some data into a template from a class, then regenerate the code by large chunks of classes is any better than just
$php5 = "The best";
require ("template.php");
<<template.php>>
echo $php5;
Again, I am the newbie here. Before I make a decision, I definitely want to know more about Smarty, it is too dang popular to ignore and makes me think I must have missed something major. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|