NYCPHP Meetup

NYPHP.org

[nycphp-talk] Smarty Templates

Dallas DeVries dallas.devries at gmail.com
Wed Nov 2 15:10:15 EST 2005


We use PHPLIB from PEAR,

http://pear.php.net/package/HTML_Template_PHPLIB

Its dead simple to use, just setting template variables and parsing template
blocks you define. Pretty much completely keeps programming logic separate
from the design phase. All that if/looping stuff is great and all but I'de
rather just handle it in the php, its not that hard. Maybe I'm just not used
to smarty but embedding php variables/method calls into the template seems
like something that will cause pain further down the line as well. The only
performance issue I have run into is if you need to parse thousands of items
on one page there is a big slow down. In these cases (like big tables) we
just embed a little bit of the html in the php.

-Dallas
SportSpyder.com

On 11/2/05, David Mintz <dmintz at davidmintz.org> wrote:
>
>
> I've noticed that if you use e.g. HTML_QuickForm (a Good Thing, IMHO) then
> you eventually find yourself almost coerced into getting involved in
> Smarty (or some other template engine), because QF's default renderer is
> just adequate for the simplest of display tasks, and customizing it
> heavily is really tedious. OTOH your Smarty templates end up looking like
>
> {if $form.lastname.error}
> <tr><td>&nbsp;</td><td>{$form.lastname.error}</td></tr>
> {/if}
> <tr><td class="label">
> <label for="lastname">Last name</label>
> </td>
> <td>{$form.lastname.html}</td></tr>
>
> which about as ugly as the other alternatives. Still, I think it's worth
> it. I have taken to sticking the form initialization work into the same
> classes that do the db access work. The result is that the PHP scripts
> that control the flow end up being short and sweet.
>
>
> ---
> David Mintz
> http://davidmintz.org/
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20051102/2fa34c6c/attachment.html>


More information about the talk mailing list