Basically, I have a menu, which works as a navigation to different pages in my application containing the title of those pages. This menu is created as a partial view. I've a folder named 'partials', inside I've my menu partial view page named 'menu_view.php'. Here's the code of 'menu_view.php':
<div id="menu" class="box">
<ul class="box">
<li id="<?php if(isset($controller_name)) echo 'selected'; ?>"><a href="<?php echo base_url(); ?>index.php/admin_logins"><span>Home</span></a></li>
<li id="<?php if(isset($controller_name)) echo 'selected'; ?>"><a href="<?php echo base_url(); ?>index.php/admin_logins/meal2"><span>Add Meal</span></a></li>
<li id="<?php if(isset($controller_name)) echo 'selected'; ?>"><a href="<?php echo base_url(); ?>index.php/admin_logins/designation"><span>Designation</span></a></li>
<li id="<?php if(isset($controller_name)) echo 'selected'; ?>"><a href="<?php echo base_url(); ?>index.php/admin_logins/employee2"><span>Employee</span></a></li>
<li id="<?php if(isset($controller_name)) echo 'selected'; ?>"><a href="<?php echo base_url(); ?>index.php/admin_logins/role"><span>Role</span></a></li>
<li id="<?php if(isset($controller_name)) echo 'selected'; ?>"><a href="<?php echo base_url(); ?>index.php/admin_logins/user"><span>User</span></a></li>
<li id="<?php if(isset($controller_name)) echo 'selected'; ?>"><a href="<?php echo base_url(); ?>index.php/admin_logins/meal"><span>Meal Information</span></a></li>
<li id="<?php if(isset($controller_name)) echo 'selected'; ?>"><a href="<?php echo base_url(); ?>index.php/admin_logins/meal_bill_config"><span>Meal Bill Configuration</span></a></li>
<li id="<?php if(isset($controller_name)) echo 'selected'; ?>"><a href="<?php echo base_url(); ?>index.php/report_meal_lists/index"><span>Reports</span></a></li>
</ul>
</div>
In order to show a certain menu item as selected, I've added an array index named 'controller_name' in the respective controller method. For instance, for the 'Designation' title to be selected, I've added the following to my controller method:
function designation() {
//i've written controller's specific code here.
//i'm not showing this as it has no relation with the question
$data["controller_name"] = 'admin_logins/designation';
$this->load->view('/admin_logins/designation_view', $data);
}
In the view page('/admin_logins/designation_view'), I've got this:
$this->load->view('partials/menu_view', $controller_name);
But I don't get my menu item to be selected.
What am I doing wrong?
Note that designation, and most other titles in my menu are from methods of a single controller named 'admin_logins', it is understandable from my code for 'menu_view.php'.
CodeIgniter - 2.2.0, PHP - 5.3.0