[eluser]Rick Jolly[/eluser]
As long as every top level category has only one level of subcategories, your example code is almost there. Maybe create a menu array that looks something like this:
Code:
$array_menu = array();
$array_categories = $this->gal_model->getCategories();
foreach($array_categories as $category)
{
$array_subcategories = $this->gal_model->getSubCategoriesFromCategory($category->idc);
// add this category and its subcategories to the menu array
$array_menu[] = array($category,$array_subcategories);
}
If you need multiple levels of subcategories you'll need to use recursion. Check out examples of "Adjacency List". You could also use "Nested Sets" which are more complicated. There are CI examples of both methods out there.