Comments for Smarty PHP template engine

07 Sep 2008 02:15 mohrt

Re: What a bad idea


> Consider the following Smary “Code”

>

> {if $smarty.session.user and (

> $user_type eq "editor" or

> $user_type eq "admin" )}

> <input type=checkbox name=edit

> value="y"> edit <br>

> {/if}

>

> That looks a lot like a programming

> language to me, and Smarty is nothing

> like HTML.

You didn't read the whole page. That is an example of what NOT to put in the template page (application logic.)

25 Sep 2007 22:06 di11rod

Re: What actual benefit do I get?
I can't believe the negativity people have posted about this clever development package. For starters, it's plain rude for someone to step up and criticize people who put their own time, energy, and money into making something for others to use for free. If you think the engineering behind it is flawed, recommend improvements, fix the code yourself, or just move along to a better project. Show a little sensitivity towards the people who got off their as$es and did something for the community.

Secondly, I have to back leeds on the performance impact of dual-layered interpretation. Anyone faulting a publishing environment for this is speaking from an academic perspective rather than years-in-the-trenches experience. Believe me. I used to travel around the country auditing web site performance and this ain't something to be worried about. Bigger performance issues can be found by:
1. Configure memory caching for Apache.
2. Turn off logging or set it up on a different device (not network-mounted, either).
3. Tune your DB. Make sure common SQL queries are set up as stored procedures. Make sure indexes are configured properly. Make sure none of your code hits the DB unnecessarily. Nested for-loops making calls to the DB for each row returned in the parent loop is a horrible drag.Oh, well. Smarty looks cool to me.Seth

19 Sep 2007 12:43 mohrt

Re: What actual benefit do I get?
Instead of regurgitating explanations here, read the "Right for me" and "Why use it" links from the Smarty home page. That should tell you plenty, and you can make an informed decision if Smarty is a good choice for your application. It isn't meant to be the be-all end-all template toolkit for PHP, it is just another tool in the toolbox.

> Hi there.

>

> I testet Smarty and had a look at the

> documentation. Now, however, there

> remain some questions.

>

> The syntax within Smarty templates is

> similar to the common PHP syntax. I

> output a variable using the notation

> {$MyVar} - in a PHP script, I would

> write <?=$MyVar?>. Then I have

> modifiers and plugins like

> "upper" doing tasks that are

> already covered by native PHP funktions

> (e/g strtoupper()) - yet the Smarty

> stuff is less flexible in use (and

> probably slower since PHP functions are

> called via the "template engine

> detour"). All in all, any template

> designer will have to dig into the

> Smarty syntax and learn it before they

> can create working templates.

>

> If I got it right, the compilation of

> templates means that files are

> translated from the "Smarty

> language" to PHP, meaning of course

> that these compiled scripts will be

> parsed again by the PHP parser on

> request.

> Nothing against that - but when the

> syntax is so similar, why do we need the

> Smarty templates in the first place?

> So from my point of view this template

> engine just looks a little like a big

> wrapper that does things you could do

> with plain PHP - and yet it is not much

> easier to use than PHP itself.

>

> With those drawbacks - tpl designer

> having to learn a "language"

> similar to real scripting, a lot of

> overhead code on every request and

> nothing really you couldn't achieve with

> plain PHP code just as easily - what do

> I get out of using Smarty?

19 Sep 2007 12:36 mohrt

Re: What a bad idea
You obviously haven't used Smarty if you think it's sole purpose is an alternative syntax for template designers. That is a very small part of it, and more of a side-effect than a purposed feature.

> Smarty is quite possibly the worst idea

> for a template engine I have ever seen.

> It says in their documentation that it

> makes it so that web page designers do

> not have to deal with PHP code syntax,

> but instead an easy-to-use templating

> syntax not much different than plain

> HTML

> (http://smarty.php.net/rightforme.php).

> Consider the following Smary “Code”

>

> {if $smarty.session.user and (

> $user_type eq "editor" or

> $user_type eq "admin" )}

> <input type=checkbox name=edit

> value="y"> edit <br>

> {/if}

>

> That looks a lot like a programming

> language to me, and Smarty is nothing

> like HTML. It is just another

> programming language with HTML embedded

> into it just like PHP. If the designer

> has to learn how to program anyways why

> not just use PHP? Now if a PHP

> programmer ever has to change something

> in the presentation layer he has to

> learn a new language. It’s kind of like

> writing a windows program in C# then

> using VB for the presentation layer.

> There really isn’t anything wrong with

> it but there is no point either, why not

> just write the whole thing in C#? That

> would save the trouble of learning 2

> languages for no reason. Smarty is just

> a big waste of time and resources.

>

20 Jun 2007 22:32 marionconsulting

Re: design problem with smarty


> while using php we can show various

> category name rowwise with more than one

> column in each row.

>

> like: using while loop with

> mysql_fetch_array()

> we can loop the result.

> within the loop if we use

> mysql_fetch_array()

> again, then the pointer jumps to

> next record.

>

> I found it impossible using smarty. We

> cant go to next record within any loop.

> For this purpose we have to make static

> pages while it can be made dynamic if

> written in raw php.

>

> if anybody faced this problem and has a

> solution pls reply.

Smarty can definitely handle the situation. Pleaes provide code and an example of exactly what you want to do and I'll show you how to do it in Smarty.

14 Mar 2007 06:51 endless552001

Re: design problem with smarty
Smarty can use foreach within foreach like below.


{foreach from=$sample item=test}

{foreach from=$test item=item}
{$item.value}
{/foreach}

{/foreach}

02 May 2006 00:33 dyuti_leo

design problem with smarty
while using php we can show various category name rowwise with more than one column in each row.

like: using while loop with mysql_fetch_array()

we can loop the result.

within the loop if we use mysql_fetch_array()

again, then the pointer jumps to next record.

I found it impossible using smarty. We cant go to next record within any loop. For this purpose we have to make static pages while it can be made dynamic if written in raw php.

if anybody faced this problem and has a solution pls reply.

30 Mar 2006 12:52 jeremys013

What a bad idea
Smarty is quite possibly the worst idea for a template engine I have ever seen. It says in their documentation that it makes it so that web page designers do not have to deal with PHP code syntax, but instead an easy-to-use templating syntax not much different than plain HTML (http://smarty.php.net/rightforme.php). Consider the following Smary “Code”

{if $smarty.session.user and ( $user_type eq "editor" or $user_type eq "admin" )}

<input type=checkbox name=edit value="y"> edit <br>

{/if}

That looks a lot like a programming language to me, and Smarty is nothing like HTML. It is just another programming language with HTML embedded into it just like PHP. If the designer has to learn how to program anyways why not just use PHP? Now if a PHP programmer ever has to change something in the presentation layer he has to learn a new language. It’s kind of like writing a windows program in C# then using VB for the presentation layer. There really isn’t anything wrong with it but there is no point either, why not just write the whole thing in C#? That would save the trouble of learning 2 languages for no reason. Smarty is just a big waste of time and resources.

15 Apr 2003 07:46 mohrt

Re: What actual benefit do I get?

> Hi there.
>
> I testet Smarty and had a look at the
> documentation. Now, however, there
> remain some questions.
>
> The syntax within Smarty templates is
> similar to the common PHP syntax. I
> output a variable using the notation
> {$MyVar} - in a PHP script, I would
> write <?=$MyVar?>. Then I have
> modifiers and plugins like
> "upper" doing tasks that are
> already covered by native PHP funktions
> (e/g strtoupper()) - yet the Smarty
> stuff is less flexible in use (and
> probably slower since PHP functions are
> called via the "template engine
> detour"). All in all, any template
> designer will have to dig into the
> Smarty syntax and learn it before they
> can create working templates.
>
> If I got it right, the compilation of
> templates means that files are
> translated from the "Smarty
> language" to PHP, meaning of course
> that these compiled scripts will be
> parsed again by the PHP parser on
> request.
> Nothing against that - but when the
> syntax is so similar, why do we need the
> Smarty templates in the first place?
> So from my point of view this template
> engine just looks a little like a big
> wrapper that does things you could do
> with plain PHP - and yet it is not much
> easier to use than PHP itself.
>
> With those drawbacks - tpl designer
> having to learn a "language"
> similar to real scripting, a lot of
> overhead code on every request and
> nothing really you couldn't achieve with
> plain PHP code just as easily - what do
> I get out of using Smarty?

This is a fairly good explanation to your questions:


http://smarty.php.net/whyuse.php

26 Oct 2002 20:18 btakita

Re: What actual benefit do I get?
Hello,


I have a project named PHP Object Oriented Framework (http://www.sourceforge.net/projects/poof/).


POOF uses PHP itself as its template engine. Nested templates are also easily supported. Using PHP as the template language means there is very little script overhead and no compilation is necessary. POOF is still in alpha stage however.


However the template syntax might be harder to use for template designers.


What do you all think about having PHP as the template language?


Sincerely,

Brian Takita

Screenshot

Project Spotlight

ReciJournal

An open, cross-platform journaling program.

Screenshot

Project Spotlight

Veusz

A scientific plotting package.