Welcome Guest, Not a member yet? Register   Sign In
Menu_model
#1

[eluser]neen[/eluser]
So I posted this in the wrong forum the other day...meant to post it here.

Anyways, here it is:

Hi there, below you'll find the menu class I am using for my custom CMS built on CI...

This has only been tested with PHP5. It will probably work with PHP4, with some major edits.

Just drop the model in your models directory and drop the below code in the __construct() function of your controller. This can be used to generate and display several menus at once such as here: http://mjohn.krob.ath.cx/menu.php, or just one menu.

This model handles side menus (ie just one menu at a time, instead of several). If you specify more than one menu in your controller, pass the $id of the menu you want to render to $this->menu->generateSidemenu() .

It also handles breadcrumbs, and lets you specify custom names for any of the URIs you may have. This is primarily meant for the backend/admin area.

Each controller can have it's own separate menu/breadcrumb initialization, or you can dump them all in one file and use a foreach() on $this->menu->menuList().

This also has a little bit of HTML hard coded into it, but it shouldn't be too hard to change it to suit your needs. This model also doesn't handle any sort of display, either, so that will be up to you to take care of.

The model is in my second post (since I hit the character limit). If you have any questions or suggestions, let me know!
Implementation:
Code:
$this->load->model('display_model', 'display');
            // setup the menu and breadcrumbs
            $this->menu->item("Content","Manage Content")->
                create("Add Content")->
                listitems("List Content")->
                delete("Delete Content")->
                registerBreadcrumb('manage', 'Manage Content')->
                registerBreadcrumb('create', 'Add Content')->
                registerBreadcrumb('list', 'List Content')->
                registerBreadcrumb('edit', 'Edit Content')->
                registerBreadcrumb('delete', 'Delete Content');
#2

[eluser]neen[/eluser]
Wow...I can't post it here...guess I'll just attach it then.

Added some bug fixes and other changes from the first post.




Theme © iAndrew 2016 - Forum software by © MyBB