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 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: switch to smarty template engine

  1. #16
    aladdin Guest

    Default

    Hello,

    Actually one of my scripts is "working" with Smarty, actually it is not working too well. Smarty does use normal html template but does not always like the content of the template. Here how it happen, you build a template for header, it will contain your HTML code and other code such as java. Smarty is suppose to do its magic to the template and put it in template_c folder (you load your template in template folder)
    1) Every time you modify your template you need to also delete it equivalent in template_c (not very convenient but I can leave with that) Smarty will re-create the appropriate template in template_c
    2) If you put java script in your template, Smarty does not like it so it will just give you an error message, you can of course edit the appropriate template and load it in template_c and it will works but it is not my idea of convenience and efficiency.

    Now when you have an error you have to ask yourself the question, did I do something wrong? did Smarty do something wrong, does Smarty not like my code. It is going to be fun and keep us on the edge. Personnaly I got enough with my own mistake!!

  2. #17
    Join Date
    Jan 2004
    Location
    Oregon
    Posts
    26

    Default

    YAY for smarty! I Will be looking forward to this =)

  3. #18
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    continued from http://www.nicecoder.com/community/s...9&postcount=13


    Quote Originally Posted by brickholius
    Waiting (for v4)...but hesitant cause scared of smarty templates.
    brick

    Quote Originally Posted by esm
    yep, you should be scared of smarty templates. I've seen them and I do not like them.

    I have enough trouble understanding PHP; I have no desire to learn another programming language. and that is exactly what SMARTY is - a programming language disguised as a template parser.

    At least I had the good sense to make my enhanced template parser an optional feature of both my LinksCoder links program and my v3.2E Enhanced version of INDEXU.


    want to see SMARTY: http://smarty.php.net/crashcourse.php



    .

    Quote Originally Posted by inspireme
    smarty is actually very well thought out, i managed to get to grips with it in a few hours, but i admit it will take a few days to really understand it.

    I wanted smarty, but i have gone to a point of no return with 3.2 so I will never be using a v4 if it ever arrives.

    Quote Originally Posted by esm
    I could agree with that. my take on SMARTY is, if you are not comfortable with reading/writing some basic PHP code, you will not feel comfortable with SMARTY.

    here is a SMARTY example
    Code:
    Name: {$name|capitalize}<br>
    Address: {$address|escape}<br>
    Date: {$smarty.now|date_format:"%Y-%m-%d"}<br>
    
    <table>
    {section name=mysec loop=$name}
    {strip}
       <tr bgcolor="{cycle values="#eeeeee,#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>
    and that is just the HTML file. you (or someone) will still need to go into the PHP file and assign the actual data values to the variables in order for the data to print in the SMARTY template.

    Here is an example of that assignment in SMARTY:
    Code:
    $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')
    	));
    just your standard array inside of an array. not much different that just plain old PHP.



    .

    Quote Originally Posted by inspireme
    considering that smarty is ment to seperate code from design
    ("code" is the same thing as "programming" and instead of "design", I would say presentation)

    Actually, I view SMARTY as just the opposite. Currently, INDEXU passes the data to the template with "no coding" allowable in the template (it is just ignored). SMARTY is "coding" and here is a simple example:


    Code:
           PHP                                            SMARTY
    echo "<table border='1'>";                        <table  border='1'>             
    echo "<tr bgcolor='lightblue'>			  <tr bgcolor='lightblue'>        
            <td>name</td>				        <td>name</td>           
    	<td>phone</td>				  	<td>phone</td>          
    	<td>age</td>				  	<td>age</td>            
         </tr>";					       </tr>                      
    for($i = 0; $i < $numofrows; $i++) {		  {section name=mysec loop=$users}
        $row = mysql_fetch_array($result);            {strip}
    
        $bgcolor = iif ($i % 2, "yellow", "white");                           
        echo "<tr bgcolor='$bgcolor'>";		      <tr bgcolor="{cycle values="#aaaaaa,#bbbbbb"}">
        echo 					                                                     
        "<td>$row['name']</td>			         <td>{$users[mysec].name}</td>               
         <td>$row['phonenumber']</td>		         <td>{$users[mysec].phonenumber}</td>        
         <td>$row['age']</td>";			         <td>{$users[mysec].age}</td>                
        echo "</tr>";				      </tr>                                          
    }						   {/strip}                                          
    		 				   {/section}                                        
    echo "</table>";				   </table>
    however, the real question is whether the separation of coding from presentation is relevant to the average INDEXU user. it's just my opinion but that rationale is relevant for large sites only. and by large, I would think a site like CNN, or Yahoo is large. For most site, the same person does both the programming and presentation.

    But I like template programs; I used an enhanced template parser for my v3.2E Enhanced version of INDEXU. Smarty just seems to be overkill for INDEXU. But SMARTY does seem to do a better job of separating coding and presentation and is fairly fast compared to a lot of the template parsers out there.



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

    .

  4. #19
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    to be honest i would have preffered having php and html mixed in the same files, it would make my life easier, it gets very complicated to add your own code currently.

    The current method is perfect for users happy to use "out of the box"

  5. #20
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    well, that is the original design of PHP -to embed PHP within the HTML. However, that makes a page more difficult to read. and the way some folks write code, it can end up a big jumbled mess. and it is hard to develop "reusable" code that way.

    I don't really like the embedded method. and dody's method of doing all the work in separate modules and just passing the data off to the HTML pages is cumbersome to work with.

    I like the approach SMARTY takes, I just don't like the idea of it being so complicated. I like to keep things simple and SMARTY is just not simple.

    Oh, well, it was an interesting discussion....



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

    .

  6. #21
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    All what you say is very true. I wonder how many of those that voted "yes" to smarty have actually used it? maybe they were all just voting on something they perceived to be easier to use? Smarty would have given me lots of flexibility, the site im making includes lots of changes so this would really have helped me. Im guessing most use indexU "out of the box" as you say the smarty code may actually confuse a lot of people who just wanted to change the look - Afterall the current <%variable%> system is as easy as it gets.

    Ps. I have written 2 sites using plog (blogging), that uses smarty templates, if you have a little php knowledge then its not as difficult as you first think. The best way to learn is get your hands dirty and use it. I have to say though that i havent tried anythign very difficult with smarty - just template changes and a little simple coding.

Similar Threads

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