[eluser]Walle[/eluser]
Hello,
I am new to CodeIgniter, and I have a question which I'm not able to resolve.
I have several views, which load a navigation menu. For example this view:
Code:
<?php $this->load->view('template/header'); ?>
<?php $this->load->view('template/navigation'); ?>
<div id="page-wrapper">
<div class="row">
<h1>Title</h1>
</div>
<div class="row">
<p>Paragraph</p>
</div>
</div>
<?php $this->load->view('template/footer'); ?>
Now my question is, I have some items in the navigation file, which have to be resolved from the database. I have created a model, which returns my data as I want it. I am able to print the data on a view, so that is all right.
Code:
<?php
class Menu extends CI_Model {
public function getMenuItems() {
$query = $this->db->query("SELECT ID, OMSCHR FROM ticket.online_help_menu_top");
$menu = array();
foreach ($query->result_array() as $row) {
$menu[] = array(
'id' => $row['ID'],
'omschr' => $row['OMSCHR']
);
}
return $menu;
}
}
I also made a controller to load the view:
Code:
<?php
class Test123 extends CI_Controller {
public function test() {
$this->load->model('menu');
$data = array();
$data['menu'] = $this->menu->getMenuItems();
$this->load->view('template/navigation', $data);
}
}
But if I load the view 'template/navigation', I logically just get a page with my menu on it, and not with all the other stuff like the example on the top of my post.
So my question is, how can I get the data from the Menu model into my template/navigation page, on another view, by just using
Code:
<?php $this->load->view('template/navigation'); ?>
inside that view?
I've been doing some research on the internet, but I wasn't able to find somehting useful on it.
If I need to post some code of the template/navigation.php file, ask it. But it is clearly simple, just a file with <ul> and <li> items, I just need to get the data in there.
I hope someone can answer my question. It would really help me out a lot.
Thanks in advance,
Jeroen