Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // I use this helper in CodeIgniter
- // AdminLTE 3 template
- // You can use for another reason
- if ( ! function_exists('set_active'))
- {
- function set_active($urls)
- {
- $_ci =& get_instance();
- $urls = explode(',', $urls);
- foreach ($urls as $url) {
- $ex_url = explode('/', $url);
- $seg = 1;
- $status = TRUE;
- if (count($ex_url) > 1) {
- foreach ($ex_url as $part) {
- $segment = $_ci->uri->segment($seg++);
- if ($segment != $part) $status = FALSE;
- }
- } else {
- $segs = '';
- while (!empty($_ci->uri->segment($seg))) {
- $segs .= $_ci->uri->segment($seg).'/';
- $seg++;
- }
- $segs = rtrim($segs, '/');
- if ($ex_url[0] != $segs) $status = FALSE;
- // var_dump('SEG: '.$segs);
- }
- if ($status) break;
- }
- if ($status) return 'active';
- return '';
- }
- }
- if ( ! function_exists('set_menu_open'))
- {
- function set_menu_open($urls, $exact = FALSE)
- {
- $cur_url = uri_string();
- $urls = explode(',', $urls);
- foreach ($urls as $url) {
- if (($exact && $cur_url == $url) || (strpos($cur_url, $url) !== FALSE) && !$exact) {
- return 'menu-open';
- }
- }
- return '';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement