![]() |
Menutree with CI - 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: Menutree with CI (/showthread.php?tid=47204) |
Menutree with CI - El Forum - 11-29-2011 [eluser]donald.tbd[/eluser] Hello, i have 3 questions about creating a menu tree with codeigniter. First of all ill explain how i do it at a moment. First I select every entery from db, i get item id, parent_id and title from there. If the parent_id is 0 then its a main item, if its something else it belongs under another parent item. Secondly i print out the main items like this: Code: <?php Thirdly as you can see after every main item i call function get_subs() The function looks like this: Code: <?php And again as you can see i check if there are any items to current main item and print them out. Now my three questions are: 1) Holding functions in a view seems kind of wrong in CI. But i cant find a better place for this? 2) I want to create a hierarchy or a tree somehow that every sub item is a bit further away from main element. How to do that? 3) Is there a better way to handle all of this? Maybe CI offers seme good helper functions i dont know about? Thanks for reading/replying! Donald. |