CodeIgniter Tree Menu - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: CodeIgniter Tree Menu (/showthread.php?tid=20572) |
CodeIgniter Tree Menu - El Forum - 07-14-2009 [eluser]neillyons.co[/eluser] CodeIgniter Tree Menu Using CodeIgniter's ul function ( line 61 ../system/helpers/html_helper.php ) to render the output for the menu, I need to generate and format an array to pass as the first parameter, can anyone help? Each menu item has a parent, which is the id of the parent menu item. If a menu has no parent selected it will default to 0. Zero is the root. Database schema: Code: menu Format of the array to pass: Code: $data["Animal"]["Mammal"][] = "Cat"; The above array when passed to ul function would produce the following HTML. Code: <ul> I need to dynamicly produce this array from the information in the database. Let me know if you can help. CodeIgniter Tree Menu - El Forum - 07-14-2009 [eluser]trice22[/eluser] Without throwing you a complete piece of code (which I wouldn't even have atm.) a quick hint: "Recursion" will allow you to climb the tree up, until you reach the end for each branch (parent == 0, e.g.). Google and the search in here are your friend and I'm happy to help out where I can as well. Besides—I believe I've seen a navigation helper, which did something similar, around. You might want to have a look in the wiki as well. Good luck, trice P.S.: @Admin: Would it be possible to rename this forum? 20%–50% of the stuff that comes in (via my feed reader) has absolutely nothing to do with "Ignited Code" and I'd blame the name. Mostly . |