RE: Smarty and speed

From: Date: Fri, 07 Dec 2001 01:03:05 +0000
Subject: RE: Smarty and speed
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2184@lists.php.net to get a copy of this message
> -----Original Message----- > From: mohrt@ns3.ispi.net [mailto:mohrt@ns3.ispi.net]On Behalf Of Monte > Ohrt > Sent: Thursday, December 06, 2001 6:27 PM > To: smarty@lists.ispi.net > Cc: smarty@lists.ispi.net > Subject: [smarty] RE: Smarty and speed > > > Rod K wrote: > > > > Speed of compilation should NOT be an issue, IMHO. I can't see why > > templates would have to change that often in a production > environment for it > > to be an issue. > > > > To be honest I've grown more and more disappointed with smarty. > Too often I > > see very complicated work arounds to enable simple layout > designs. Maybe > > I'm off base here but isn't the reason to use a template system > to enable > > the designers to design without bothering the programmer? We > can't expect > > designers to come up with complicated structures. Yes, *I* can > write the > > structures, but I can't ask an HTML person to do so, and if *I* > have to do > > it anyway, there's no need to use the template engine. It > seems to me that > > the number of people posting to this list (and be inference, > using smarty) > > are basically the script writers, since the features being > asked for entail > > concepts that go beyond what the designer should be concerning > himself with, > > yet simple features that would give great power and flexibility to the > > designer and WOULDN'T require them to have to grasp a difficult coding > > concept are unavailable. > > > > Just my $.02 American. > > I'd like to know specifically what complicated workarounds you are > referring to. The ability to do simple modifications to a section index. See this post: http://marc.theaimsgroup.com/?l=smarty&m=100687852210821&w=2 > Of course the idea is that designers should be as self > sufficient as possible. But another strong point is that layout logic > _must_ be separate from business logic. I fail to see how those are mutually exclusive. > Sometimes the programmers have > to help out, such as complicated section loops. I envision the ability to train designers to implement templates. The type of structure outlined in the above linked response is too complicated for designers, IMHO. Yes, there will be times when a hand needs to be held, I want to minimize that occurrence. > Realistically, how do > you get around that? Water down the syntax thus decreasing flexibility? > Move layout logic back into the application logic? (go ahead, I won't do > it ;-) But if the layout logic in the template is too complex it overrides any benefit of separating the layout logic from the application logic. Let me explain again where I am coming from: Designers design. I don't want them to have to understand anything too complex, but I DO want them to be able to make simple layout changes without assistance (beyond the first time). If the structure is too complex for them to understand then they WON'T be able to duplicate it in another project. Maybe I don't give enough credit to designers, I only have my experiences to work with. > You have to work together to a certain degree, and there are > tradeoffs at just about any point. If you have some ideas that would > help ease your disappointment, I'd like to hear them. Ok, look at this: {section name=sec1 loop=$links} {if %sec1.first%} <tr height=35 bgcolor="{if %sec1.index% is even by 4}#cccccc{else}#ffffff{/if}"> {/if} <td align=center width=25%><a href="{$links[sec1]}">{$makes[sec1]}</a></td> {if %sec1.index% is div by 4} </tr> <tr height=35 bgcolor="{if %sec1.iteration% is even}#cccccc{else}#ffffff{/if}"> {/if} {if %sec1.last%} </tr> {/if} {/section} Granted this code isn't quite correct. It is printed here exactly as Andrei provided in his email. I don't have the working code that I massaged this into with me at the moment. Now look at this: {section name=sec1 loop=$links step=4} <tr height=35 bgcolor="{if %sec1.rownum% is even}#cccccc{else}#ffffff{/if}"> <td align=center width=25%><a href="{$links[sec1]}">{$makes[sec1]}</a></td> <td align=center width=25%><a href="{$links[sec1+1]}">{$makes[sec1+1]|default:"&nbsp"}</a></td> <td align=center width=25%><a href="{$links[sec1+2]}">{$makes[sec1+2]|default:"&nbsp"}</a></td> <td align=center width=25%><a href="{$links[sec1+3]}">{$makes[sec1+3]|default:"&nbsp"}</a></td> </tr> {/section} I showed the designers I work with the first section, and explained the object of the code and how it worked. Only 1 (out of 5) admitted she was totally lost (BTW, she happens to be our BEST designer), the rest assured me they completely understood. However, when I asked them to modify the code so it worked with 2 columns in the table, not one came even close. 3 columns? Forget it, that breaks the bgcolor calculation required ({if %sec1.iteration% is even} won't work with an odd column). Not only that but the undoubtedly already ugly structure doesn't allow for "&nbsp;" to be appended to columns 2,3 and 4 if need be. Adding that is trivial but would have made the code much more unreadable. When I showed them the second bit of code, everyone understood it and could easily modify it to work with any number of rows. Unfortunately that syntax won't work with Smarty as it is now. My point is that the template syntax needs to be structured in such a way that an HTML designer can understand. I think too much has been taken for granted and it's been structured with the assumption that the designer understands more than a non-script writing designer would. Yes some simple constructs need to be taught, but complex structures should not need to be involved, except in rare circumstances. That's when I'd be willing to hold their hand. After all, if I'm going to have to teach them how to write a structure like Andrei's example, I might as well teach them enough PHP to do the loop themselves in PHP, making Smarty superfluous.

« previous php.smarty.general (#2184) next »