NYCPHP Meetup

NYPHP.org

[nycphp-talk] Zend FW + Smarty

Paul M Jones pmjones88 at gmail.com
Wed Mar 22 15:21:48 EST 2006


On Mar 22, 2006, at 2:13 PM, Jon Baer wrote:

> Is this bad?
>
> http://kpumuk.info/php/zend-framework-using-smarty-as-template-engine
>
> Things Im really puzzled by are why (even by choice) the template
> engine is just not bundled to begin with ... wouldn't it be a benefit?
>
> Seems like repeating work if you ask me ... any thoughts?

I'm going to be lazy, and re-post (in entirety) my response to a  
similar question on the Zend Framework list.  Hope this helps.  :-)


----


Subject: Re: [fw-general] Template system, form handling and time  
schedule
Date:    March 19, 2006 11:09:51 AM CST
Cc:      fw-general at lists.zend.com

On Mar 19, 2006, at 10:25 AM, Ralf Eggert wrote:

> The possibility to use PHP in the templates is good, very good. But I
> still think it might make sense to offer other template solutions.

There are literally dozens of template solutions in userland; each of  
them meets specific needs and desires, and none of them is really  
compatible with the others from the controller's point of view.

The internal debates at Zend on what template system to use were  
never resolved successfully; there are those at Zend who *love*  
PHPLIB templates as the "one true way".  There are others who think  
Smarty is the end-all be-all of templates.  Then there are the PEAR  
template categories:  Flexy, IT, etc et al ad nauseum.

So which of these techniques should Zend adopt as the blessed  
system?  The answer is: none.  Zend picked the simplest thing that  
could possibly work with all of the PHP template systems in  
userland:  PHP itself.

Thus, Zend_View exists not as a template system, but as a standard  
way for the business logic to hand over control to presentation  
logic.  Within the presentation logic encapsulated by Zend_View, you  
are free to do as you wish.

As you say, some developer/designer teams need an extra layer of  
intermediation or simplified markup.  In these cases, your Zend_View  
scripts should activate the template engine of your choice,  
manipulate it as you wish, and then have the engine generate the  
output.  To illustrate, here are two flavors of a view script, one  
using plain PHP, and the other using PHPLIB templates.

http://framework.zend.com/manual/en/zend.view.scripts.html

http://framework.zend.com/manual/en/ 
zend.view.scripts.html#zend.view.scripts.templates

Note that the controller doesn't need to know anything about the view  
in these cases; it just gives the view its variables, and then the  
view script takes care of everything else.  This is what Zend means  
when they say that Zend_View is template-system agnostic; the system  
works for Smarty, PHPLIB, and everything else out there.



--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository
for PHP5.   <http://solarphp.com>

Savant: The simple, elegant, and powerful solution for
templates in PHP.   <http://phpsavant.com>





More information about the talk mailing list