• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
menu

#1
[eluser]Unknown[/eluser]
how to generate menu from database simple code new in codeigniter

#2
[eluser]Krystian[/eluser]
you need to create a database table that contains at least menu_label, menu_link

then you need to create a model method to retrieve records from this table

Code:
$query = $this->db->get('yourTableName');
return $query->result();


run this in your controller and pass it to the view
in controller
Code:
// load your model

$data['menu_items'] = $this->your_model->get_menu();
$this->load->view('view_file', $data);


and in view file
Code:
<ul>
foreach($menu_items as $menu_item)
{
     echo '<li>' . $menu_item->menu_label . '</li>';
}
</ul>


then style your li list as you need, add <a > tag with menu_link


#3
[eluser]siptik[/eluser]
You can create a library that will generate a menu or create a model that will return menu items.
But there is no universal code, since each has its own application structure.
if the menu is generated from a single table, use Krystian's code.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.