Re: templates?



WebRod wrote:
Hi,

i want to rewrite my website to separate the php script from the HTML code.
Therefore a web designer can update the design of the website without any knowledge in PHP.


I read a lot of information about several templates like PhpLib, FastTemplates, Smarty etc etc.
*snip*
My question is, what is the interest to learn another language??
What is the real interest of Smarty (or other one)?

The only advantage I can see is that these things force you to separate presentation logic from the rest of your code, as they aren't general purpose enough to do all that php can.


Using php for templating doesn't require all that much restraint imo (you know things will get messy really fast if you do things the ugly way), so I'd never introduce one more layer of complexity.

So I really think it's better to have;
- a php script which set some variables
- a HTML templates which build the content of the page. It uses a lot of HTML tags and of course some really basic php function (if, foreach, echo).


Of course the php script call the HTML template.
You only use php, you work with the same variables, you don't need to call some specific functions (assign etc etc), you don't need to know another language etc etc.

Agree completely. My php projects consist of a controller/request handler step (usually with a front controller/dispatcher in front of that) and a display step.


The request handler usually calls out to object oriented business logic which builds some kind of data model, and then include() the proper template (which may of course include other templates again, but no other php code).
For very simple stuff I sometimes drop the oo stuff and manage with just request handler and template.


Am I wrong??

Is there any interest to use Smarty (or other one)??
Why do they exist??????
And maybe why do YOU use them????

Manys thanks

Rod


.



Relevant Pages

  • Re: Dividing PHP and HTML - maybe easy
    ... One way to completely separate PHP & HTML is to use Templates. ... PEAR Home: http://pear.php.net/ ...
    (comp.lang.php)
  • Re: Why php and not C?
    ... > Leaping from php to C is one thing, leaping from C to assy is another. ... With todays IDEs running a test on a php script vs ... You can have an html page and embed php in it, where as with perl / c you ... it is very simple to convert an html site into a dynamic php site, ...
    (comp.lang.php)
  • Re: Tool to validate HTML code with PHP tags?
    ... I do not want to validate the output of a php page, ... My php code NEVER provides HTML code. ... If I work on the output, I have to manually update all the templates!! ...
    (comp.lang.php)
  • POST in Apache server
    ... I'm new in the php world and I have a problem. ... ipt from a web page hosted on an Apache server. ... I use in the html to invoke the php script: ...
    (php.general)
  • Re: Generating forms - XML or PHP?
    ... templates changes XML code into HTML with conditional expressions ... in PHP and variables (until the template class doesn't compile ... class generates the HTML form. ...
    (comp.lang.php)