alexweber15 Posted September 18, 2009 Share Posted September 18, 2009 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) thanks! Quote Link to comment https://forums.phpfreaks.com/topic/174653-solved-mvc-smarty-best-practices/ Share on other sites More sharing options...
RichardRotterdam Posted September 18, 2009 Share Posted September 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/174653-solved-mvc-smarty-best-practices/#findComment-920557 Share on other sites More sharing options...
alexweber15 Posted September 18, 2009 Author Share Posted September 18, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/174653-solved-mvc-smarty-best-practices/#findComment-920832 Share on other sites More sharing options...
alexweber15 Posted September 19, 2009 Author Share Posted September 19, 2009 I realized this will be an issue I could potentially have in other parts of my application so I decided to include Zend_Registry and use it to share object instances between classes in my application Quote Link to comment https://forums.phpfreaks.com/topic/174653-solved-mvc-smarty-best-practices/#findComment-921235 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.