Thursday, August 30, 2007

Zend Framework and Smarty Integration Tips

Just got Zend Framework 1.0.1 and Smarty to work together!!!


ain't that easy...


here's what i did:







    here's the code in my bootstrap:

    // Different view implementation
    //$view = new ZF_Smarty();
    $smarty_config = array(
    'compile_dir' => './smarty/templates_c/',
    'config_dir' => './smarty/configs/',
    'cache_dir' => './smarty/cache/',
    'debugging' => true,
    );
    $view = new Zend_View_Smarty('./application/views/scripts/', $smarty_config);

    $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
    $viewRenderer->setViewBasePathSpec('./application/views/scripts/')
    ->setViewScriptPathSpec(':controller'.DIRECTORY_SEPARATOR.':action.:suffix')
    ->setViewScriptPathNoControllerSpec(':action.:suffix')
    ->setViewSuffix('tpl');
    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);




3 comments:

Anonymous said...

Hey, my post (http://my.opera.com/zomg/blog/2007/07/31/smarty-zend-view-take-three) is about ZF version 1.0.0, so it should work with version above that since there haven't been any changes in the view classes since 1.0.0

Anonymous said...

I am curious... Are you using Smarty with the Zend Framework because you feel that there are some distinct advantages in doing so? Or is it that you and/or your designers are just accustomed to using it now?

I have used Smarty on a few sites and I never felt that it was all that advantageous. ZF seems to make the passing of data to the View fairly easy and with it being such a hassle to integrate Smarty, I am just wondering if you think it is worth it? Maybe I am just missing some big advantage, but I don't see it...

Beach_Blogger said...

dnoe,
Smarty template code can be edited in dreamweaver easily. PHP in dreamweaver is displayed in an odd way making dreamweaver pretty useless for crafting the html.

(btw, sorry about the delayed response, but blogger did not notify me of your comment)

About Me

I'm a web dude and this is my geek blog. There should be lots of content ... if I'm working hard ...