One more thing.
I was wondering how you would incorporate Smarty support in that little
example.
I'm thinking about using the Smarty class shown on this page:
http://framework.zend.com/manual/en/zend.view.scripts.html#zend.view.scripts.templates
I do wonder where I would put the "Zend_View_Smarty" class, how to load it
etc.
As I was looking for the same info (ie: where to place our custom files
in the tree), and as I did not find any relevant answer, I created a
directory called "classes" inside the "application" folder. My structure
is as follow:
- application
--- classes
------ Smarty // containing the whole Smarty app
------ Zend
--------- View
------------Smarty.php // containing the code in the url you mention above
* I added this new "classes" folder to my include_path, then I load the
Smarty stuff via the index.php, using
Zend_Loader::loadClass( 'Zend_View_Smarty', array( 'classes' ) );
* Make sure that the automated render is not anymore entering into action:
$yourFrontController->setParam("noViewRenderer",true);
* You then have to deal with the view, to make sure it's a Smary view.
Not being sure if it's the finest way to do this, and based on my little
knowledge of the ZF, I did this in the index.php:
$view = new Zend_View_Smarty( );
$registry->set( 'view', $view );
* Then, inside the init() method of a controller, I can get back the
Smarty view instanciated above:
$registry = Zend_Registry::getInstance();
$this->view = $registry->get( 'view' );
* After that, I can assign you variables to your view, inide a
Controller method:
$this->view->foo = "bar";
* Finally, I render the view inside a Controller method:
echo $this->view->render( 'mytemplate.tpl' );
BTW do not forget to configure your Smarty (template_dir) to point to
the directory where the views are stored.
There should be a nicer way to do this, I'm wide open to suggestions as
well :)
--
Ludo
Thank you.
Rob Allen-3 wrote:
I've updated the source file download for the tutorial and have tested
it on ZF 1.0.1:
http://akrabat.com/wp-content/uploads/zf_tutorial-140.zip
If you want the ZF included:
http://akrabat.com/wp-content/uploads/zf_tutorial-140-with-zf.zip
Regards,
Rob...