I'm building a CodeIgniter application and using Smarty as my templating system. Instead of trying to assign Smarty variables from various controllers, would i开发者_运维问答t be better to define all the Smarty variables in one place (e.g. a controller super-class) so that everything is in one place? My concern with this approach is that assigning variables not needed for a particular controller/view pair might degrade performance.
Ideas?
All in one place != Good
Keep your template variable assignments by the code that's assigning them. Not only will this be way simpler to maintain, it makes more sense because it should be the controller assigning the template variables directly (not through some intermediary). Also, more than one controller could use a template and they could be assign variables via different rules.
精彩评论