forked from bcit-ci/CodeIgniter
-
Notifications
You must be signed in to change notification settings - Fork 0
DynamicMenu
World Wide Web Server edited this page Jul 4, 2012
·
24 revisions
Menu library. Will show/hide sub-menus depending on in which, uri->segment the user is browsing. Just add it in to autoload.
[code] $menu = array( anchor('account', 'Account'), anchor('news', 'News'), anchor('ticket', 'Support') );
$sub['account'] = array( anchor('account/secquestion','Security'), anchor('account/password','Password'), anchor('account/user','Profile') );
$sub['news'] = array(anchor('news/post','Post'));
$segment = $this->uri->segment(1); foreach($menu as $k => $v){ $menutmp[$k] = $v; if (strripos($v, $segment) !== FALSE){ $menu[$menu[$k]] = $sub[$segment]; unset($menutmp[$k]); $menutmp[$menu[$k]] = $sub[$segment]; } } $menu = $menutmp; [/code]