Article:
  The Dynamic Duo of PEAR::DB and Smarty
Subject:   This is not separating logic from presentation
Date:   2003-04-23 17:18:23
From:   anonymous2
Response to: This is not separating logic from presentation

No, you are not getting the point. Any logic flow control should not be in the templates because this simply rules out that majority of the real presentation designers.


If you need to iterate over the same template, like in alternating table row colors, just do it in the programming. That is what programming is meant to be, control the program output logic flow.


Template engines like Smarty that make you handle any logic in the templates are not a great improvement over the traditional PHP programming. They require you to learn a third language that is neither PHP nor HTML.


Properly conceived templates should only contain HTML, placeholders and delimiters, so they can be edited in any HTML editor and any good graphic designer can do his job and not have to learn that third language.

Main Topics Oldest First

Showing messages 1 through 2 of 2.

  • This is not separating logic from presentation
    2003-05-06 04:32:20  anonymous2 [View]

    Well, you're right when you say:

    If you need to iterate over the same template, like in alternating table row colors, just do it in the programming. That is what programming is meant to be, control the program output logic flow.


    However, how should the programmer know which color to iterate over and how to specify it? It's the HTML designers job to say "use color a and b". The programmer tells the designer that this row will be repeated for an unknown number of times and then the HTML designer has to come up with a good representation.

    I don't see what's wrong with this.

  • This is not separating logic from presentation
    2003-04-24 09:14:15  anonymous2 [View]

    >> Any logic flow control should not be in the templates...

    I felt exactly the same way for a very long time. I had heard of smarty for months before I ever actually tried it. I didn't like it. Putting looping constructs inside a html file! WTF?!

    However, I decided to just try it because of all the rave reviews I had seen and I'll never go back.

    Trying to wrap my head around the fact that there is 'code' in the html was tough. This method was as bassackwards as I could imagine. I stuck with it though...I just made some example pages to become familiar with it then I modified some existing pages from phplib to smarty and WOW. The ease of editing the smarty pages and the power available in smarty changed how I've programed every php application since.

    So, my advice is to try it out. It may not be for you....I didn't think it was for me, but damn was I wrong.

    Tom