User Guide & Reference Manual

Menu Model

Menus are managed at Layout > Menu Manager. This model, however, allows you to programmatically modify menus, clear the menu cache, etc.

Menus are cached to reduce the number of database queries per page load. Menu data is stored in cache files automatically.

Initialization


$this->load->model('menu_manager/menu_model');
// methods: $this->menu_model->new_menu(), etc.

Method Reference

void clear_cache ()

Clear the menu cache files. This should be called whenever a menu or link is modified.

int new_menu (string $name)

Create a new menu.

int add_link (int $menu_id , int $parent_link , string $type , int $link_id , string $text [, string $special_type = FALSE [, string $external_url = FALSE [, array $privileges = array()]]])

Add a link to a menu. "Special" links have some magic in that they may generate multiple menu items, or dynamically modify their menu items, depending on other factors. The following are special links:

int update_link (int $menu_link_id , string $text [, array $privileges = array() [, string $class = FALSE]])

Update an existing link.

void remove_link ()

Remove an existing link.

array get_menu ($menu_id)

Retrieve a single menu referenced by its ID, in the same format as get_menus().

void delete_menu ($menu_id)

Delete a menu and all of its links.

array get_menu_by_name ($menu_name)

Retrieve a single menu referenced by its name, in the same format as get_menus().

array get_menus ( [array $filters = array()])

Retrieve a menu or menus based on optional filters.

Possible Filters:

Each menu has the following data:

array get_link (int $id)

Return a single link, in the format of get_links()

array get_links ( [array $filters = array() [, boolean $no_cache = FALSE ]])

Return one or more links based on optional filters.

Possible Filters:

Each returned link has the following data: