I'm developing a php application and enforcing a strict mvc pattern whenever possible. I have a view,the header of the page, which should change the background image depending on the current month. Where should I place the php logic to decide which image to use as the Background? Inside the view file or on the caller (The parent file which includes the view)? If I put the code in the caller then I have to replicate the logic for each page (Every page has the same header view). I could put the logic inside the view, avoiding code duplication, but should a view supposed to have only view code? (no business logic)?
1条回答 默认 最新
- duanchi0897 2016-09-18 10:23关注
keep in mind that view is not a template for the application. View is that piece of code that has the responsibility for the UI. So the logic for the background definitely belongs to the view. Also at classical MVC you have 1view 1controller ratio (UserView-UserController etc)
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报