The Dynamic Duo of PEAR::DB and Smarty
Subject:   This is not separating logic from presentation
Date:   2003-04-24 09:14:15
From:   anonymous2
Response to: This is not separating logic from presentation

>> 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.


Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • This is not separating logic from presentation
    2003-06-05 12:40:35  anonymous2 [View]

    I totally agree.

    I needed a way to seperate the presentation data and logic from the business logic... since someone else will be editing the html after I am done with the code.

    I thought of simply printing the HTML myself and allowing them to change it via CSS. However, this proved to be cumbersome. It allowed them to only change the look of components, and not change the components themselves... plus the CSS files were getting to be too big.

    So I read an article on yesterday about seperating business logic and presentation. One of the comments linked to this article as well as the Smarty site. I was a bit skeptical.. thinking I would probably just write my own template engine. However, I gave Smarty a shot after reading this article, as it seemed very easy to use and very easy to learn (face it, for an experienced programmer, the "language" takes 2 seconds to learn). I LOVE it so far. It has made me feel so much better about writing my code and not worrying about the presentation. It will be easier for the guy who I'm writing this for to manage.. he does know some programming, so it's not like the templates will baffle him.

    I appreciate this article and wholy recommend Smarty to anyone to wants a good templating engine with some power. Given that speed isnt critical that is.
    • This is not separating logic from presentation
      2003-07-10 00:18:36  anonymous2 [View]

      I agree too.
      As a graphic designer, Smarty seems very good solution for templating. The good point of Smarty is that, when the designer wants to change a color or any visual aspect of presentation, he can do it without asking to programmer, without touching to any program code.

      Actually I work for a web site with PHPLIB. I have to switch between template files and php codes in order to change/preview/confirm and I'm sure if, after my changes in the php code, everything goes still fine in the business logic side...