Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    135
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Why use a templating engine?

    Why?

    It just seems pointless... If your doing websites where your both the designer and the owner.

    It's no fun, and you don't learn as much either.

  • #2
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    If you mean Smarty, there are lot's of reasons to use it. But if you are still new to OOP in PHP, then using template engines will not help you to improve your skills. Also smarty is not simple for beginner developers, and it's wrong to think that newbies use it. Most developers use Smarty only when they are sure in their OOP, and when they created few of their own template engines, and now can see why smarty is, as lot's of them say, a best way around...

  • #3
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    They allow you to segregate your php (processing code) from your html (output formatting code), making it faster and easier to maintain both. Also, they allow you more flexibility if working with a team - ie: the web designer needs to know little about php.

  • #4
    New Coder
    Join Date
    May 2007
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Initially this is also what I thought. I recently began using smarty and while I am no expert here are a few benefits I rather like:

    1) It is easier to focus on the code on the programming side without having lots of html in your line of sight

    2) If you start dealing with lots of different Web sites you can easily pull components from one Web site and use them on another

    3) You can avoid spam indexers by using {mailto} function and still display an email on a Web page. Crawlers can't understand the email, but normal Web browsers display it in human readable format.

    There probably are other reasons, but I find some benefit with Smarty.

  • #5
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    My take on smarty or similar, template based systems, is that all the advantages are on coder's side, very little for the designer's side.

    The majority of designers tend to use gui programs and wysiwyg html editors. Try throwing a smarty template into DW and watch it croak. Templating systems make the php developer's job easier and the designer's job a sh!tload harder.

    Smarty syntax and markup looks no less confusing to a designer than php does. In fact, when things like image, css and js paths are tied up in smarty code, the whole layout goes to hell in any editor.

    Ever since I started php coding, I have always practiced keeping php as separate as possible from the html. In one of the studios where I work atm, none of the designers have any complaints about my php/html pages since all the pages render fine in their editor of choice.

    When a project involving smarty comes along, guess who gets lumped with converting flat image files to html? Not the designers; one look at smarty and they jump ship.

    The exception to my generality about designers are hand coding designers who spend a lot of their time in code view. They tend to understand what's going on a lot better and develop tactics to overcome smarty's penchant for buggering up paths to external media.
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #6
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    While I agree that templating engines do present their own challenges. But in my experience, these can be overcome with a little careful project planning.

    True, smarty templates (and others, of course) don't play well with any wysiwyg design view that I've seen.

    However, I have found designers that understand smarty (no doubt, the hand-coding variety). But also, I have worked with the strictly wysiwyg type of designer as well. Even in those case, it streamlined the development process by allowing the designer to dummy-up the pages. True, I was left to "smarty-ize" the template, but I would have been slicing up their design and inserting into my php anyway.

    That said, templating engines are most certainly not a solution for everyone, but one in which I find more benefits than pitfalls.

  • #7
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    One surpremo advantage of smarty, despite my above post, is skins and caching. Templating systems are hard to beat for speeding up html output and user selected skins. The OO overhead of using smarty may be contradictory for performance in smaller sites; but for serverside resource heavy sites, smarty template caching is a treat.
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #8
    New to the CF scene
    Join Date
    Aug 2007
    Location
    Bogota
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I use a template engine always

    Hi

    Yes, I use always a template engine no matter if I am the designar and the programmer at the same time, and no matter if my project is small or big.

    I agree that its not easy for beginners, and when I teach php in my classes I first begin with the php tag, but for professional projects I always do the effort so I will gain in maintainability.

    I love xtemplate. I dont like smarty but I not against the people who use it.

    I wrote an article about it in my blog. Its here: http://socialviva.com/index.php?idSe...ogid=6&lang=en

    Thanks and have a good php time


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •