View Poll Results: So, do you agree? I hope so.

Voters
27. This poll is closed
  • Yes, I agree.

    24 88.89%
  • No, I do not agree.

    1 3.70%
  • I'm getting confuse.

    2 7.41%
  • I don't care.

    0 0%
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: switch to smarty template engine

  1. #1
    dody is offline Administrator
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,731

    Thumbs up switch to smarty template engine

    Please give us any feedback, do you agree if we switch template engine to smarty (http://smarty.php.net). It's the most powerful template engine, very fast, and complex too. But do not worry, indexu will make it simpler, as simple as current templating. But you always have choise to use its advance features.

    Here're some of its features:

    • It is extremely fast.
    • It is efficient since the PHP parser does the dirty work.
    • No template parsing overhead, only compiles once.
    • It is smart about recompiling only the template files that have changed.
    • You can make custom functions and custom variable modifiers, so the template
    language is extremely extensible.
    • Configurable template delimiter tag syntax, so you can use {}, {{}}, <!--{}-->, etc.
    • The if/elseif/else/endif constructs are passed to the PHP parser, so the {if ...} expression
    syntax can be as simple or as complex as you like.
    • Unlimited nesting of sections, ifs, etc. allowed.
    • It is possible to embed PHP code right in your template files, although this may
    not be needed (nor recommended) since the engine is so customizable.
    • Built-in caching support
    • Arbitrary template sources
    • Custom cache handling functions
    • Plugin architecture


    The impact in indexu template are:
    • Change tag from &lt;%indexu_variable%> to {$indexu_variable}
    • Since smarty support if.. else... statement, then there're some complicated reduction in file msg.php. For sample case is login box that is now stored in msg.php. With smarty it's very handy in index.html using {if $logged}.......... {else}....................
    • Smarty have bloc/section template, mean looping data fetch like displaying links. This feature will not used by indexu to prevent complicated design. Indexu 4 still use file template to display link and others. rows.html is still used. No change in this form.

  2. #2
    marcele is offline Registered User
    Join Date
    Feb 2002
    Posts
    2

    Default

    I have used smarty with the X-cart shopping cart software... and it is AWESOME!!!! In conjunction with phpaccelerator (a free php cacheing program .. www.phpaccelerator.co.uk) we saw 10X speed increase plus!!! SMARTY ROCKS!!!!

    from the site:
    PHPA is free, and not only the top performing non-commercial solution of its kind, but also a match for the commercial alternatives. Delivering typically up to a 5 times speed gain and with a near 10 times speed-up measured with some Smarty based applications, sites such as Yahoo! have found PHPA to be the ideal PHP script caching solution. The testimonials give some user reactions to PHPA

  3. #3
    dody is offline Administrator
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,731

    Default

    Yes, I agree. Smarty works wonderful with php optimizer too. Not sure how many web host already install php accelerator, but zend optimizer seem the most popular
    www.nicecoder.com
    www.dodyrw.com

  4. #4
    shalida is offline Registered User
    Join Date
    Jun 2003
    Posts
    14

    Default

    I am for anything that is fast but get worried when you use the word "complex". As it is I think the current template format is complex! Anything that is fast, simple and intuative would be awesome!

  5. #5
    esm's Avatar
    esm
    esm is offline Active Member
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    well, I have been fooling around with computers since my first programming class in 1967. This is my position:

    While there are varying degrees of complexity and ease of use, if it is powerful then it is complex; if it is easy then it is not powerful. Powerful requires lots of effort to learn but the results are usually outstanding.

    While I have never used smarty templates, I am very familiar with how they work thru another product I used.

    I think smarty templates will allow you stiil follow the way they are currently done while adding a degree of functionality to the templates that is really needed ( desparately, might be a better word instead of "really") .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  6. #6
    dody is offline Administrator
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,731

    Default

    I think smarty templates will allow you stiil follow the way they are currently done while adding a degree of functionality to the templates that is really needed ( desparately, might be a better word instead of "really") .
    Yes, it's correct
    That is what I would like to do.
    www.nicecoder.com
    www.dodyrw.com

  7. #7
    richhead is offline Registered User
    Join Date
    Jul 2003
    Posts
    60

    Default

    I'm all for something easier on the template front... but would probably not upgrade having spent an inordinate amount of time getting my site looking vaguely how I want it to. Wouldn't want to have to go through all that again

  8. #8
    esm's Avatar
    esm
    esm is offline Active Member
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    yes, I can understand that!

    however, the power of such templates may very well seduce you into using them, depending on your situation.

    For the most part, those that see the power offered thru truly customizable templates bite the bullet and use them.

    There were two things that have kept me with INDEXU. The ease of customization (mods/hacks) and the promise of smarty templates. OK, three things - dody is nice!
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  9. #9
    richhead is offline Registered User
    Join Date
    Jul 2003
    Posts
    60

    Default

    I tend to be lazy once I've got a site much as I want it.... unless I'm forced to upgrade (e.g. browser compatability isssues), I tend to not want to do anything I don't have to.....

    But I take your point about "truly customisable templates" and will probably not be able to resist the temptation! :-)

  10. #10
    esm's Avatar
    esm
    esm is offline Active Member
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    "I can resist everything but temptation" - Oscar Wilde
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  11. #11
    esm's Avatar
    esm
    esm is offline Active Member
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    any comments/suggestions on installing the smarty template software ourselves and playing around with it???
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  12. #12
    dody is offline Administrator
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,731

    Default

    there're a lot of scripts using smarty in hotscripts.com
    www.nicecoder.com
    www.dodyrw.com

  13. #13
    esm's Avatar
    esm
    esm is offline Active Member
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    Originally posted by dody
    there're a lot of scripts using smarty in hotscripts.com
    Having fooled around with various links programs over the past 3+ years, I am familiar with Tempate Parsers. For example, in G-T Links 2, the program came with a template parser to control things in the template. And one user wrote an enhanced template parser to offer more control. And another user wrote an advanced version of the enhanced template parser. But the largest was only 500 lines of perl code. so while they allowed us to do a good bit, they were not complex.

    But before we all jump on the SMARTY bandwagon I think we should consider the issues raised by the following discussion:

    http://www.sitepointforums.com/showt...hreadid=67849. Pay close attention to comments by voostind especially his second post on that thread ( the really long one that discusses template parsers ).

    I looked at SMARTY. Downloaded it and played around with it a little. As I learned more PHP I began to wonder why do I need to learn another progamming language? And make no mistake, SMARTY is a programing language. But it is not as sophisticated as PHP.

    Then I discovered that PHP is actually a template parser just like SMARTY ( actually, I already knew it, I just did not understand it ). The HP in PHP stands for Hypertext Preprocessor. And what Hypertext does it process? The Hypertext in HTML – HyperText Markup Language. An where do we find HTML? In the INDEXU templates (well, mostly in the templates ).

    Here is a quote from the voostind post: "...template engines like Smarty are a complete waste of our precious time. Luckily these packages are generally freely available, or they would be a complete waste of money as well. They do not add any features to PHP not already there, and by using them, dynamic web sites become more complex, a lot slower, and harder to maintain."

    Here is some info from the SMARTY website.
    Smarty facilitates a convenient way to loop over arrays of data with the section function. Here's an example of that, and we also threw in alternating row colors via the cycle function, and we use the strip function to strip out newlines and white space.
    Here is what a SMARTY template could be like...
    index.php
    include('Smarty.class.php');

    // create object
    $smarty = new Smarty;

    // assign an array of data
    $smarty->assign('name', array('bob','jim','joe','jerry','fred'));

    // assign an associative array of data
    $smarty->assign('users', array(
    array('name' => 'bob', 'phone' => '555-3425'),
    array('name' => 'jim', 'phone' => '555-4364'),
    array('name' => 'joe', 'phone' => '555-3422'),
    array('name' => 'jerry', 'phone' => '555-4973'),
    array('name' => 'fred', 'phone' => '555-3235')
    ));


    // display it
    $smarty->display('index.tpl');


    index.tpl
    <table>
    {section name=mysec loop=$name}
    {strip}

    <tr bgcolor="{cycle values="#eeeee,#dddddd"}">
    <td>{$name[mysec]}</td>
    </tr>
    {/strip}
    {/section}

    </table>

    <table>
    {section name=mysec loop=$users}
    {strip}
    <tr bgcolor="{cycle values="#aaaaaa,#bbbbbb"}">
    <td>{$users[mysec].name}</td>
    <td>{$users[mysec].phone}</td>
    </tr>
    {/strip}
    {/section}

    </table>


    output
    <table>
    <tr bgcolor="#eeeeee"><td>bob</td></tr>
    <tr bgcolor="#dddddd"><td>jim</td></tr>
    <tr bgcolor="#eeeeee"><td>joe</td></tr>
    <tr bgcolor="#dddddd"><td>jerry</td></tr>
    <tr bgcolor="#eeeeee"><td>fred</td></tr>
    </table>

    <table>
    <tr bgcolor="#aaaaaa"><td>bob</td><td>555-3425</td></tr>
    <tr bgcolor="#bbbbbb"><td>jim</td><td>555-4364</td></tr>
    <tr bgcolor="#aaaaaa"><td>joe</td><td>555-3422</td></tr>
    <tr bgcolor="#bbbbbb"><td>jerry</td><td>555-4973</td></tr>
    <tr bgcolor="#aaaaaa"><td>fred</td><td>555-3235</td></tr>
    </table>
    You can see the SMARTY code in red. I don't know about you, but that sure looks like programming to me.

    My question is why don't we just use PHP instead of SMARTY to parse the templates? That is what it was designed to do...

    Anybody have any comments?
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  14. #14
    tjoerg's Avatar
    tjoerg is offline Active Member
    Join Date
    Jul 2002
    Posts
    189

    Default

    HI esm,

    I just read thru the whole discussion you mentioned. Right now I haven't made myself a clear opinion whether we should use SMARTY or not. I'm not that deep into programming to get the whole view. But here are some of my thoughts:

    Indexu already uses some kind of template system. It's stored in function Display(). This works well for me! And it seems that this functions are pretty fast. I don't know how much SMARTY slows down the speed. But I gess it will be somewhat slower.

    So why should we use SMARTY? From what I found at the smarty.php.net website it that it gives you a lot of instructions (programming language) for template layer. But the other question is, do we need al that stuff? And are all Indexu Users willing to learn some kind of programming?

    One final quote from the discussion:
    I bet my hat on it that in less than a year Smarty has evolved so much that for many developers it has become too complex (heck, we already see that now). These developers then either fall back on another, simpler engine, or decide (like me) not to use such an engine at all.
    So I peronaly tend to use the "template engine" as it its right now. Much more important will be that all Indexu layout can be controlled by an external CSS files!

    Joerg
    --------- applying hacks require a knack ---------

  15. #15
    esm's Avatar
    esm
    esm is offline Active Member
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    the one thing that I found I really needed from a "template parser" was the IF statement. For example, I might have a field called acct_type with possible values of free and paid. My detail form would look something like:

    <%IF acct_type="Free"%>
    here would be the free type display
    <%ENDIF%>
    <%IF acct_type="Paid"%>
    here would be the paid type display
    <%ENDIF%>
    Yep, I know how to do it in PHP. But it just makes sense to do it in the template. I think this is where the separaration between the coding and the content seems to be. But I am not a software engineer. At best I am just a hacker...make that a wanna-be-hacker...

    I think a good template parser would contain

    • IF/ELSEIF/ELSE
    • support for boolean in IF
    • maybe an include stmt
    • maybe a loop stmt ( a big maybe )

    But I would be happy with an IF statement with boolean.

    yeah, the Display function is where it is at...almost too much so. You have to be careful while wading thru it all...

    In all honesty, I am beginning to believe that while SMARTY templates would look good in the advertising for INDEXU, it might be overkill for the average INDEXU user.

    PS: Take a look at the EvalTemplate function. it is quite a function!!!
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

Page 1 of 2 12 LastLast

Similar Threads

  1. $15 for Indexu Commercial Template Pack!
    By Veg in forum Templates
    Replies: 18
    Last Post: 01-21-2005, 05:13 PM
  2. Undestanding templates
    By dody in forum Tutorials, Hints & Tips
    Replies: 2
    Last Post: 01-04-2004, 04:37 AM
  3. Replies: 3
    Last Post: 04-24-2003, 05:31 PM
  4. Template
    By csengine in forum Templates
    Replies: 3
    Last Post: 04-12-2003, 08:01 PM
  5. Replies: 6
    Last Post: 11-11-2002, 03:31 AM

Posting Permissions

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