Reputation: 77
I'm brand new to the MVC coding style and i'm having trouble deciding if i placed my code in the right place. I have a list of rates for an item, the rates have various time frames. what i want to do is display the highest rate per item for the current day. so say if item 1 has 3 rates, and 2 of them overlap today, it will choose the highest of those 2 rates and display it.
I placed this in the view since it applies to the way i am displaying the data. this is in cakephp so it's a web platform if that changes the way you think the controller/view should be applied.
Upvotes: 0
Views: 148
Reputation: 3967
i separate reusable view code into elements. and put elements in its respective controller folder inside elements folder. so a page controller would have a element folder call /app/views/elements/page
Upvotes: 0
Reputation: 31300
I typically put all of my logic in the controller and model so that my view only has markup and output statements. This will keep your views much cleaner and, especially if you are in a place where non-programmers might be editing views (e.g.: front-end implementors or content people), you run less of a risk of them messing things up.
Generally, I prefer thin controllers compared to models, and even thinner views (thin relating to the amount of logic in each division).
Upvotes: 1