Well, I can't say that it's a 'good' tutorial, it's a little messy,
but it's along the lines of how I am using it ... If you want to have
a look, I put together a page and some explanations and stuffed it
into an archive (162Kb) You can downlad it at
http://www.wegotit.at/sm_demo.zip

If you're going to look at it, drop me a line to let me know if it's
too confusing or if you could actually make something out of it :)

Richard

Thursday, April 8, 2004, 9:11:06 AM, you wrote:


> Does anyone have a 'good' tutorial about Smarty. The one
> available on smarty.php.net is really basic...


> Vincent


> -----Original Message-----
> From: Robert Cummings [mailto:[EMAIL PROTECTED]
> Sent: jeudi 8 avril 2004 4:02
> To: Kelly Hallman
> Cc: PHP-General
> Subject: Re: [PHP] smarty


> On Wed, 2004-04-07 at 21:35, Kelly Hallman wrote:
>> Apr 8 at 10:26am, Justin French wrote:
>> > PHP itself is a great templating language :)
>> > <h1><?=$title?></h1>
>> > <table>
>> > <? foreach($staff as $person): ?><tr>
>> > <td><?=$person['firstname']?> <?=$person['surname']?></td>
>> > <td><?=$person['role']?></td>
>> > <td><?=$person['phone']?></td>
>> > <td><a
>> href='mailto:<?=$person['email']?>'><?=$person['email']?></td>
>> > </tr><? endforeach; ?></table>
>> 
>> Uhhh, yeah--that's not a templating, that's called spaghetti code :)
>> 
>> You get the concept. Smarty, as you know, basically takes a Smarty
>> template and writes PHP code similar to what you've done above, then
>> writes out the .php file, and includes it when you render your template.
>> So you'd get nearly the same effect by writing the PHP as a separate file
>> and including it as your last step, and it acts as your display logic.
>> 
>> That may be acceptable to you, as a PHP programmer. If you're the only one
>> who ever needs to modify your templates then that's great, more power to
>> you. I'm sure that you would have no problem having many levels of nesting
>> all over the place and not screwing anything up. So be it. But that's you.
>> 
>> I guarantee another person not as adept at PHP will screw that code up,
>> and there is less potential for that with a Smarty template. If you know
>> PHP as well as yourself, it should be plain to see how Smarty is just a
>> wrapper over PHP that makes templates easier to build and maintain.
>> For a designer or non-coder, Smarty will be easier to learn than PHP.
>>  
>> Unless your needs never exceed the very basics like you have demonstrated
>> above, you'll be hosed when another person needs to modify your template.
>> Which goes back to a templating truism never in dispute: if this is all
>> you want templating for, it's six of one, half a dozen of the other.
>> 
>> However, there are practical limitations on what you can easily accomplish
>> with this approach, and Smarty addresses those issues. And you're worse
>> off if you invest a lot into building your sites this way, and then
>> realize you need some better templating strategies later.
>> 
>> > You can still separate your logic from your presentation, template
>> > designers can still use quick, simple "tags" to include code, and the
>> > upside is that people familiar with PHP don't need to learn ANOTHER
>> > language (that's what Smarty is) -- they can dive straight in.
>> 
>> You can consider it it's own language, but really it's more like PHP with
>> different formatting. Which is why it's different than what you're doing
>> above--it's designed to facilitate templating. Your method is just poking
>> in variables and PHP into inline'd HTML. It works, but you're missing some
>> of the power of Smarty if you think that's all it's good for.
>> 
>> > The question is, do you want to give your templater designers full
>> > access to the power of PHP, or not.
>> 
>> In other words: are your template designers already good PHP programmers?
>> It's not just hype, it solves real problems, even if you don't have them.

> Smarty is a bit of a hack too... why do I need to declare my templates
> within the PHP code? If I'm an HTML designer I'd like to create a new
> page, include templates, use some data that's been made available and
> have it all in the template. I sure as heck wouldn't want to have joe
> programmer edit the main page, add support for importing my template.
> This is the thing that bugs me about Smarty, its still got that hanging
> dependency. And it's still got to include all those templates within the
> source code.

> InterJinn is superior in this respect. You use XML tags to import other
> templates, you use XML tags to load modules and components, and you use
> XML tags to do almost any kind of expansion you want. Of course, you can
> go ahead and use something else, InterJinn provides the ability to plug
> in custom compilers. InterJinn compiles to PHP code, includes are
> INCLUDED at compile time not at run time. So given this scheme anyone
> working on the HTML is already familiar with the syntax... hard to go
> wrong with:

>     <jinn:template path="topnav.template"/>

> Hell you can even overload HTML tags. Not only that but Interjinn allows
> recursive includes of templates and source files, and these includes can
> be relative to the outer nested template or source file. Furthermore,
> there's nothing forcing the use of the InterJinn application layer so
> InterJinn can be used entirely for it's templating features, in which
> case it provides a faster resulting PHP page than using PHP include().

> Cheers,
> Rob.
> -- 
> .------------------------------------------------------------.
> | InterJinn Application Framework - http://www.interjinn.com |
> :------------------------------------------------------------:
> | An application and templating framework for PHP. Boasting  |
> | a powerful, scalable system for accessing system services  |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for       |
> | creating re-usable components quickly and easily.          |
> `------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to