Jump to content

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


alexweber15

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)

 

thanks!

Link to comment
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 comment
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 comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.