noob building menus - is there a better way? - 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: noob building menus - is there a better way? (/showthread.php?tid=13735) |
noob building menus - is there a better way? - El Forum - 12-03-2008 [eluser]cfraz[/eluser] I'm converting an existing PHP spaghetti code application to CI and this is what I've done so far to build the menus. There are 4 or 5 different menu "sets." Each page may use 1 or more menu sets in different combinations. Each menu set becomes a class instance and consists of a label to identify what kind of menu it is, and an array of menu items. Each menu item is a 2 element array of URI string and menu text. My questions: 1. Is using a /library/class with a factory class a good way to build the menus? 2. Menu elements are defined by multi-dimensional array assignment. This works, and should be relatively easy to maintain, but it looks kinda' klugey to me. Isn't there a more elegant way to do this? In /library/Menu_builder.php: Code: <?php if ( ! defined('BASEPATH')) exit('Direct script access is not allowed.'); In the controller: Code: function index() noob building menus - is there a better way? - El Forum - 12-03-2008 [eluser]Rey Philip Regis[/eluser] Quote:My questions: For me building a menu which has many categories and sub categories, using factory pattern is a good implementation. As for me also using array is the most effective way of defining element in your array easy to see and understand. Good day.. noob building menus - is there a better way? - El Forum - 12-03-2008 [eluser]cfraz[/eluser] Thanks, Rey. I'll just plow ahead, then. |