Created
March 11, 2022 07:42
-
-
Save mhcifci/8af00998d6fbdee4cb3ed381f7344ceb to your computer and use it in GitHub Desktop.
CodeIgniter 3 - Menu Active Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Use function in helper file */ | |
function activeMenu($menu = ""){ | |
if ($menu != "") { | |
$t = &get_instance(); | |
if ($t->uri->segment(2) == $menu) { | |
return "active"; | |
} | |
} else { | |
return "active"; | |
} | |
} | |
/* Eg: <?= activeMenu("test") ?> *test is your uri segment "2", ex. blabla.com/test . Very Simple! :) */ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment