I have a webpage where I am trying to create a contextual menu depending on the category of the page being browsed. If the category is on animals, the segment based url will contain animal, ie. http://www.mywebbie.com/livingthings/display/category/animals.
To build the contextual menu, I will need to access my database table subcategory with columns subcat_id, subcat_name, cat_id and select all rows with cat_id corresponding to that of animals.
Should I access the database (via the model method) from the controller, then pass the array containing the subcategory names to the view? Or should everything be done within the view, where there is code that loads the model method that returns an array of subcatergories?
Btw, I'm using PHP framework Codeigniter.
Yes, The controller takes care of communicating with the model and handling the data, the view takes care of presenting the data.
Make the data available to the view from the controller, in the most simple form, lets say a simple array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With