Welcome Guest, Not a member yet? Register   Sign In
Dynamic Menu
#2

[eluser]obiron2[/eluser]
I think you need to be a bit more specific about what you are trying to achieve.
MVC patterns are designed so that each piece of the puzzle is independent of the next.

Put your menu data into a model. I don't know what you will need but as a minimum:
Menu title,
Page link (a hrefSmile
Whether this is the currently selected menu option.

Prep these as either a multi-dimensional array or an object collection.

$menu = array( array ('Title'=>'Home' 'Link'=>'Welcome'),array('Title'=>'About Us' 'Link'=>'Welcome/aboutus'))

return the array from the menu method.

Now in your controller load the menu_model and call the menu method then serve the array up the view as part of the $data collection. You can parse the menu array (or object collection) in the view.

When this is all working, You can then make the menu_model get the data from a database rather than being static. Your database table would need to have the following.

MenuID, SortOrder, Title, Ref

Your model would call a query "SELECT Title, Ref from MenuTable WHERE MenuID = $menuID Order by SortOrder"
and return the query->result_array() to the controller.



Messages In This Thread
Dynamic Menu - by El Forum - 07-18-2012, 12:44 AM
Dynamic Menu - by El Forum - 07-19-2012, 06:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB