RE: Smarty and speed
| From: | Monte Ohrt | Date: | Mon, 10 Dec 2001 01:09:18 +0000 |
| Subject: | RE: Smarty and speed | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2230@lists.php.net to get a copy of this message | ||
Hi Pablo!
Pablo wrote:
> Hey Peter,
>
> Thanks for the nice reply. I am still here...
>
> The issue with my rant is that the original post I placed on the list seems
> to have turned into a "Pablo doesn't have experience, so he can't
> understand..." type of thing. I even get responses saying, "If you don't
> understand why templating is so important then you just don't get it".
> That's a little frustrating. None-the-less, I apologized for my rant. But
> I think I should be clear on a couple of things.
>
> I have been using PHP since it was a joke. I program daily in PHP and have
> programmed in many other languages. I have used FastTempaltes and PHPLIB
> templates EXTENSIVELY. I am not new to templating. I have used Smarty as
> the basis for my project at www.phpshop.org and have the potential to make
> it the standard for our user base of several thousand. In working with
> Smarty (we have it fully integrated with phpShop) I realized that since we
> approach our development using the MVC framework (model-view-controller),
> Smarty was not really giving us the type of abstraction we needed from the
> business logic in an effective way for designers. That is, Smarty was doing
> nothing more beneficial for us than replacing PHP.
>
> Sure, it offers caching and some other cool things, but realistically, it
> was not keeping our designers away from having to code the display logic.
There's a misconception... of course your designers have to code display logic!
One goal behind Smarty was to separate the content from the layout. The goal was
never to keep "logic" entirely out of the template language, and that really
isn't feasible. The designers _have_ to do some logic to have the flexability
they need to design a page however they wish. How would a designer alternate
table colors without some sort of IF logic? They would have to go back to the
programmers and have them pass this information as content to the template,
which doesn't get us anywhere... layout formatting is _not_ part of the content!
So when we say content is separated from layout, there is logic on both sides:
the logic that gets the content assigned to the template (what programmers take
care of), and the logic that controls the layout (which is what designers need
to have!). The bulk of the logic in the template language should be no problem
to your typical designer: includes, ifs, config file loading, etc. Section loops
are probably the single most difficult thing, and this is an area that we
haven't been able to make easy, and there probably just isn't any easy way to do
it. Either you have programmers help with section logic, or you have designers
with both sides of the brain. In our case, we always setup section logic in
skeleton templates before designers get a hold of it. This works perfect.
Monte
>
> The reality is that there is probably no way to separate the two. So, in an
> effort to understand if Smarty was more in-line with our future plans, I
> posted a general list of questions asking for the "arguments for Smarty".
> What I received was not giving me the warm-fuzzies I was looking for. In
> reality, using PHP/HTML to "output" of your pages is just like using Smarty.
> All you need to do is be 'smarty' about how you code. For example,
>
> <?php
>
> $my_array = array("var_1" => "Home Page",
> "var_2" => "Welcome to my home page");
>
> include("mytemplate.php");
> ?>
>
> Inside mytemplate.php:
>
> <? include("header.tpl");?>
>
> <H1><? echo $my_array["var_1"]; ?></H1>
>
> <? echo $my_array["var_2"] ?>
>
> <? include("footer.php") ?>
>
> As you can see, it looks almost like Smarty templates do. And if you want
> caching, why not use Last-Modified and If-Modified-Since headers as defined
> in HTTP/1.1? That can be done quite easily.
>
> Anyhow, to make a long story short, we are moving the project to XSL. We
> will still leave Smarty as a plug-in those who want to use it. We will
> also offer PHP/HTML as we do now. But, when it comes to our
> 'recommendations', we will be promoting XSL all the way. Sure, XSL still
> requires designers to code logic in their XPATH statements. But, I'd rather
> go XML than simply replace PHP with Smarty for display purposes. It just
> doesn't make sense. Plus, XSL allows you to go from XML to
> XML/HTML/WAP/whatever... Yeah, I know... Smarty does too... But in that
> case I'd simply use PHP.
>
> Pablo
>
> -----Original Message-----
> From: Peter Bowyer [mailto:reywob@f2s.com]
> Sent: Sunday, December 09, 2001 5:08 PM
> To: Pablo; smarty@lists.ispi.net
> Subject: Re: [smarty] RE: Smarty and speed
>
> At 04:22 PM 12/9/01 -0500, Pablo wrote:
> >I apologize for being nasty. I just hate being treated like "I don't get
> it".
>
> Brent didn't deserve your rant Pablo. Your two opposing views are a
> question of relativity... from Brent's point of view as a *proper* (as
> opposed to PHP) programmer the Smarty template system really isn't like
> programming. From your point of view (and I am assuming that you do not
> have Brent's experience - my humble apologies if you do) Smarty seems like
> a programming language (I prefer to call it a macro language - it helps me
> to do my job much more easily).
>
> For a designer who understands javascript (as some do) then Smarty won't
> pose any problems. For those that are pure designers, it will.
>
> I know people find Smarty difficult if they are only used to HTML - I've
> come up against this problem. Just remember that these same people are
> going to have to grapple with XSLT within the next 5 years (something which
> is far more complicated, and IMNHO blurs the separation between logic and
> presentation even more).
>
> In the past I have asked myself the same questions as you have been asking
> on this list. I'm still not happy about mixing some logic with the display
> like Smarty does (I keep feeling there must be a 'perfect' solution, but I
> can't think of it!), but then I think that if this is what XSLT is going to
> do, there can't be much wrong with the idea :-)
>
> Use Smarty when it is useful. Use other tools when they suit the job
> better. I also worked with PHPLib templates for a long time, and I find
> Smarty to be much easier to use _because_ it mixes some logic in the code
> -the number of times an {if} statement in a PHPLib template would have
> simplified my code are too many to count (have you ever had to
> conditionally delete blocks from a template?)
>
> I suggest you think of Smarty as I do, and treat it as a macro
> language. On large, complicated projects it does save time.
>
> Thank you for reading so far, and goodnight :-)
> Peter.
>
> --oOo--
> Narrow Gauge on the web - photos, directory and forums!
> http://www.narrow-gauge.co.uk
> --oOo--
> Peter's web page - Scottish narrow gauge in 009
> http://members.aol.com/reywob/
> --oOo--
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/