[eluser]invision[/eluser]
Hi,
I have the following architecture for my web site:
Code:
Home
About Us
- Location
- The Team
Vacancies
News
Contact
My
SQL table for the Menu currently looks like this:
Code:
id | title | url | category | main
1 | home | /index.php/page/ | 1 | 1
2 | about us | /index.php/aboutus/ | 2 | 1
3 | location | /index.php/aboutus/page/location | 2 | 0
......
Now, I want to take this data from my SQL table and display it in an unordered list in my web page. N.B. Whenever it's '1' in
main category, this means it's the home page of a category.
So ultimately my HTML would be something like:
Code:
<ul>
<li>Home</li>
<li>About Us
<ul>
<li>- Location</li>
<li>- The Team</li>
</ul>
</li>
<li>Vacancies</li>
<li>News</li>
<li>Contact</li>
Here are some snippets of code I'm already using...
Controller(page.php)
Code:
$data['cats'] = $this->MPages->getPages();
Model(MPages.php)
Code:
function getPages(){
$data = array();
$Q = $this->db->get('pages');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[$row['id']] = $row['title'];
}
}
$Q->free_result();
return $data;
}
Nav View(nav.php)
Code:
<?php
if (count($cats)){
foreach ($cats as $id => $title){
echo anchor("page/$slug/",$title)."<br/>";
}
}
?>
However, I've got a bit stuck at this stage.
Anyone brave enough to help me out with this?
Many thanks for any pointers.