i want to make a 'calendar object' which generates three different style calendars to display, they'll all use the same data. should i do the logic for the calendar style in the view, or should i do that in the controller and then call it from the view?
A:
I'd personally design it so that only entities within a certain date range were passed to the view and leave all the logic regarding how to render it to the view.
There's nothing stopping your from cleaning breaking down the view further than that, but it's a view's concern, not a controllers.
Allain Lalonde
2009-08-16 23:19:49
that's the planfunction cal_month($room, $month, $year)is the sample i pass the room I'm grabbing calendar information for and then a range for the information.i wasn't sure if i should have a few loops to scan through the data and display it in the view or if i should just have a function call in the view to bring in that information from the controller. normally since i'm displaying it i'd just throw it in the view, but since it's an interactive object i'm thinking of it more like a button. in which the display is part of the logic
Adrian Guido
2009-08-16 23:48:10
cakephp has in addition to models views and controllers, items called elements and components, components are pieces of logic that can be reused throughout various controllers, and elements are views that are meant to be reused in various situations. what i wanted was an element. so i can create the calendar logic and reuse it in various situations. thank you for your input though, i agree that if i didn't have elements, the view would be the most appropriate place for the code.
Adrian Guido
2009-08-17 03:30:18
edit: i just found that after i had written the code to go into the view, luckily it was just a copy/paste and then an 'element' call to get it working.
Adrian Guido
2009-08-17 03:30:54