Re: general question about smarty
| From: | Luc Saint-Elie | Date: | Wed, 23 May 2001 13:53:23 +0000 |
| Subject: | Re: general question about smarty | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-788@lists.php.net to get a copy of this message | ||
En réponse à Wolfram Kriesing <lists@kriesing.de>:
Hello
Important Note : the following is my opinion (not an expert one by far) :
1) Yes Smarty is cool and really increase productivity
2) Smarty can be seen has a clever implementation for php of the MVC (model view
Controller) concept
3) Smarty is not "language independent" but the template concept (and therefore
the underlying MVC concept) is language independent. If you want a good example
of this point you may want for example to have a look to Velocity project, a
more sophisticated template system written in and for Java from the java Apache
group (http://jakarta.apache.org)
Although I don't really imagine this happening in "real Life" , if you have a
web site written with Smarty and suddenly want to have it written in Java, the
translation to Velocity will not be a huge work (the translation of the
underlying programming logic can be...)
To address some of your questions :
>what are the advantages of using smarty besides
>being independent from the output format (html, xml, ...)
I would formulate the question in the opposite sense : you not only are free
form the output format (its interesting but not so extraordinary) but you are
also independent of the input functionality.. and this is (for me) much much
more interesting.
With a template system you have a real separation between the logic (that
creates the data), the data vehicle (an array) and the data display system (the
template)
If you change completely the logic, as long as the array is the same..
absolutely no problem
A very little example (without any real interest but its just for the example):
For my web site I build some parts using XML that is more convenient for me and
allows me to learn XML, then once I'm happy with the result, in some case I
write down a database version.
With Smarty this is of absolutely no problem there is no logic in the interface,
all the logic is in the pure php file, as long as the array produced is the
same... the way its produced has no importance.
>what are the advantages of using smarty besides
>calling a template from the code instead
>of including code in the html
You can't loop through data in a HTML page
.. so you'll be stuck to static data
> Why should i learn a new "scripting language", if i can also use
> PHP instead of the smarty language. Just to replace the "<?php ?>"
> by "{}"?
Its not really about learning a "scripting language". Smarty language is very
simple (and can't be complicated because the goal of the system is to have the
logic out of the display..)
What is not so simple for a no-developer like me is that a template system (and
therefore Smarty) requires to be very at ease with array manipulation (and in a
template system like Smarty you can be in situation to use really complex
arrays)
>is the webdesigner really free from seeing source code,
>if he now gets to see another scripting language instead
>of php, the smarty language?
In theory YES.. in Real Life things are less obvious.
Smarty is so cool that you do sophisticated things with it and when things get
sophisticated you start to have a lot of thing in your templates.
For example in the site I'm working on the display is not the same depending if
the user is registered/connected or not registered/connected, that means there
are a good bunch of {if}{/if} in the main template in addition to the loops
through arrays
.
But its without comparison with a classical PHP/HTML page
Note : I'm unable to answer to question 4 (that seems to make a lot of sense)
Luc