SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thoughts on Template Systems?

    *Not sure where to post this*

    What is everyone's opinion on using "templating systems"?

    I am reading a book on PHP and the author is using Smarty, and I find it extremely difficult to follow and understand.

    The author makes it sound like Smarty will make the website easier to develop and maintain, but I just don't see how.

    This is one time where I feel like I am going backwards after reading a book...

    Some guru advice/wisdom is definitely needed!!!

    Sincerely,



    TomTees

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    The concept is basically that the template for the page is kept as separate as possible from the PHP that defines how the page works. That means that the template can be easily modified completely independently of the PHP and so is far easier to maintain than if the template and PHP are jumbled together.

    Smarty is just one particular way that has been developed for creating this separation. Anything where you write the template using HTML with markers in it where the content is to be substituted and then have PHP that reads in the HTML with markers and replaces the markers with the content will achieve the same end result so the only advantage Smarty has is that it is already written and so saves you having to write the PHP for it yourself.

    Of course any other server side language can be used for it as well instead of PHP if the particular templating system is set up to use that language.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    The concept is basically that the template for the page is kept as separate as possible from the PHP that defines how the page works. That means that the template can be easily modified completely independently of the PHP and so is far easier to maintain than if the template and PHP are jumbled together.

    Smarty is just one particular way that has been developed for creating this separation. Anything where you write the template using HTML with markers in it where the content is to be substituted and then have PHP that reads in the HTML with markers and replaces the markers with the content will achieve the same end result so the only advantage Smarty has is that it is already written and so saves you having to write the PHP for it yourself.

    Of course any other server side language can be used for it as well instead of PHP if the particular templating system is set up to use that language.
    I understand the concept of inserting variables into database forms, web pages, etc. to separate the presentation from logic, but the way this author does things *seems* loopy?!

    It is hard to explain things without you reading the book I'm working from, but between using object-oriented code and Smarty, things seem very complicated.



    TomTees


Bookmarks

Posting Permissions

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