I'm trying to implement a menu navigation and its content. I don't have any issues to get datas in Model.
My current problem is loading dynamically each item on right place. I've been stucked on that. :(
I want to be able to load each page content when the user clicks on each menu item.
Ex:
Folio -> site.com/index.php/className/method/1 (Get the ID=1)
About -> site.com/index.php/className/method/2 (Get the ID=2) ...
I'd appreciate if there's a way to optimize and simplify the structure.
Here's my code so far Controller:
public function index() {
$data = $this->loadPage();
$this->load->view('content', $data);
}
public function loadPage($categoryID=1) {
$data['title'] = $this->tabPageData;
$data['tabMenu'] = $this->model->getAllMenuItems();
$data['tabPhotos'] = $this->model->getAllPicturesByCategory($categoryID, 'url, model');
return $data;
}
In my Content View:
$this->load->view('top_header.php');
$this->load->view('menu.php');
$this->load->view('photos.php');
$this->load->view('footer.php');
...
Menu View:
<?php foreach ($tabMenu as $item) : ?>
$url = "<ul><li><a href='loadPage/" . $item->cat_id . "'>" . strtoupper($item->name) . "</a></li></ul>";
echo $url;
<?php endforeach; ?>
...
Photo View:
<ul>
<?php foreach ($tabPhotos as $item) : ?>
<?php echo "<li><img src=". base_url() . "images/photo1/" . $item->url. "></li>"; ?>
<?php endforeach; ?>
</ul>