Jump to content

[SOLVED] MVC + Smarty... best practices?


Recommended Posts

We're in the process of rewriting our biggest app MVC-style.


The code is a complete mess but the one solid thing is the templating done with Smarty, so we want to stick with it.


I don't really have any Smarty experience and I'm not sure how to properly implement it in the MVC context; what's better?


- Instantiate the class every time its needed (ie the controllers)?

- Instantiate the class once during the bootstrap process and pass it as a parameter to the controllers?


(right now its a global variable, which afaik isn't ideal)



Link to post
Share on other sites

I personally don't like smarty much because I think it's syntax doesn't make anything better. You may want to look at the following thread that discusses smarty http://www.phpfreaks.com/forums/index.php/topic,266164.0.html


However I do like how Zend_Layout handles things as it concentrate on the html output of a certain controller by building a view. I think cakePHP handles this very similar as ZF does (not sure though). Readup on how the views are handled in the different MVC frameworks available as you might want to get rid of smarty entirely.

Link to post
Share on other sites

Hey DjKat thanks for the feedback!


I totally agree with you and personally I don't use Smarty at all but, at the end of the day, I don't have much of a choice in this department!


The rest of the developers on the team are very enthusiastic about it and all the templates are ready to begin with!  So really whether I like it or not we're using it!


I'll read up on Zend_Layout and hopefully it will point me in the right direction!

Link to post
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.