A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

Zend Framework with Smarty Templates

Here is a post by zomg from #zftalk.

So, we want to have a nice syntax for calling Zend’s viewhelpers from Smarty templates. First, we have some issues we have to find solutions for:

* Smarty does not “know” about View Helpers
* View helpers may need arrays or associative arrays as parameters. Smarty has no support for doing this out-of-the-box

The first one is quite simple to solve: Since the Zend_View class knows about viewhelpers and can call them, the SmartyView class also does that. Since we need to create a new class based on Smarty anyway, we can add a method for saving the View instance to it so that the new Smarty class can also call view helpers.

The second one needs more work. Since Smarty’s syntax for passing parameters to functions differs a lot from the typical syntax, we need to think of a nice Smarty-like way of passing arrays and associative arrays as parameters. We also need to dig in the Smarty compiler class which converts the Smarty templates into PHP code. Isn’t it great that I did the digging for you and you can just read about it here?

Click here.

OT: Smarty reminds me of Xoops. I am following the ACL of Xoops in my Zend Framework Apps. Zend_Acl is too complicated for me :(

This entry was posted in General and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>