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.