![]() |
Need to integrate navigation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Need to integrate navigation (/showthread.php?tid=32733) |
Need to integrate navigation - El Forum - 08-02-2010 [eluser]makkal[/eluser] Hi everybody, I am working in a web application development. In that i want to keep my navigation as a dynamic one. It should 3 level navigation menu by showing the active page. Please give your suggestions on how to manage this. Is that i need to write any common functions in helper or plugins and calling it in the controller. Or some kind of function directly calling in view. Kindly let me know your ideas. Thank you. -Mak Need to integrate navigation - El Forum - 08-02-2010 [eluser]mlage[/eluser] Check out the Template Parser class (not automatically loaded) http://ellislab.com/codeigniter/user-guide/libraries/parser.html It allows for dynamic creation of menus from a view. That or you will have to write the php code to take your data that represents the menu, and through some kind of loop, make a string of the data and load it. You can load strings of data, like a view, like this: Code: $string = $this->output->get_output(); //Gets currently loaded views I'll be watching this thread... so if you need help, just post back Need to integrate navigation - El Forum - 08-03-2010 [eluser]makkal[/eluser] Hi mlage, Thanks for your reply. I am seeing the template parser used for the navigation. But is it possible to keep this code as general function to be called in all pages. Now it seems that we need to repeat this navigation code in each page. Please advise me on this. Thank you. -Mak Need to integrate navigation - El Forum - 08-11-2010 [eluser]mlage[/eluser] The keywords of your statement that hurt my eyes to read... "we need to repeat this navigation code in each page" Programming is beautiful in that one of its purposes is to prevent repeating code. So to answer your question, yes you can keep it as a general function. There are many ways on doing this... I would look into writing a short library that has one class with the functions you want... then you load that library for whatever controller needs it and call the appropriate functions. Check out this: http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html Any other questions, just post back here Need to integrate navigation - El Forum - 08-12-2010 [eluser]umefarooq[/eluser] as mlage say there are many ways you can do this, if you don't want to use library then you can use base controller put you navigation code in base controller like MY_Controller extend you controller with MY_Controller and call navigation code in your views, check base controller how they work http://www.philsturgeon.co.uk/news/2010/02/CodeIgniter-Base-Classes-Keeping-it-DRY 2nd check widget there are two type widget available in ignited code section one with CI loader and on as plug in which one you like its up to you both will work great with CI loader http://ellislab.com/forums/viewthread/161374/ plugin http://ellislab.com/forums/viewthread/109584/ |