Menu system based on model names - how? |
[eluser]Jaketoolson[/eluser]
Currently, I am porting over a web system built entirely in PHP (no MVC, little OOP) over to CI. The primary use of this site is not CRUD, but mainly model-based algorithms. The main focus of the site is providing graphs, charts, and raw data to customers all of which is driven by forms the user interacts with. This data needs to be email-able, download-able in CSV format, and more which is why I'm moving it to a MVC method. The site navigation menus are directly link to the name of models. Heres an example of my controller code (using this url example: http://site.com/index.php/reports/model_name) : Code: class Reports extends MY_Controller Is there a way I can pull the names of the models dynamically and generate the sites navigation? Is there a better way I can go about creating a dynamic menu based on model names? I'd just hate to maintain an array manually of the file names myself.
[eluser]bubbafoley[/eluser]
You can use the directory helper to get the contents of a folder. If we're still in your controller and assuming there are no models in subdirectories: Code: $this->load->helper(array('directory','inflector', 'html', 'url')); then in the view nav.php Code: <ul class="nav">
[eluser]Jaketoolson[/eluser]
wow that directory helper is AWESOME. I can move files into subfolders within the model folder and this would also reflect the menu/submenu structure! Thanks for this info! also inflector helper is another one I've yet to use and would have never considered it for this. Thanks again! |
Welcome Guest, Not a member yet? Register Sign In |