How to create menu in codeigniter
At First set your base_url in config file (if not set).!
sadanandkenganal/activelink_codeigniter.md
#Add active class to menu in codeigniter
In codeigniter, it’s very easy to add active class to the current menu in menu item.
Follow the below steps.
Step 1:- Create a file called "menu_helper.php" inside "application/helpers/menu_helper.php" and paste the below code.
<?phpif(!defined('BASEPATH')) exit('No direct script access allowed'); if(!function_exists('active_link')) { functionactivate_menu($controller) { // Getting CI class instance.$CI = get_instance(); // Getting router class to active.$class = $CI->router->fetch_class(); return ($class == $controller) ?
'active' : ''; } }?>
Step 2:- Load above helper in your controller (go to controllers/yourcontrooller.php).
Forum.codeigniter.com › showthread.
OR Load above helper in .autoload (go to config/autoload.php and add below code).
$this->load->helper('menu');
Step 3 :-. Add class to your menu. pass your controller name in activate_menu() method.
<li class="<?phpechoactivate_menu('home'); ?>"><a href="<?phpechosite_url();?>">Home</a></li> <li c