[eluser]überfuzz[/eluser]
I'm in the middle of mustering a one level menu. The menu is going to have two different css-classes. 'menu' and 'active' added if the url is right. The array used to render the array, an example:
Code:
Array
(
[0] => Array
(
[segment] => home
[name] => Home
)
[1] => Array
(
[segment] => agenda
[name] => Agenda
)
[2] => Array
(
[segment] => contact
[name] => Contact
)
[3] => Array
(
[segment] => etc
[name] => Etc
)
)
I'm looping through the array in a view-file to get the html code.
Code:
<div id="menu">
<ul>
<?php
foreach($menu AS $value)
{
$class = ($this->uri->segment(1) == $value['segment']) ? 'menu active' : 'menu'; //Nu är active = "menu active" och normal = "menu", ändra i fall du vill ha det på något annat sätt.
echo "\n\t\t<li>";
echo "<a >".$value['name']."</a>";
echo "</li>";
}
?>
</ul>
</div>
I would appreciate some pointers on this matter. For instance, is there a nicer CI-way of doing this? How do you render your menus..?
Edit, the a href="" part isn't displayed properly..?