Welcome Guest, Not a member yet? Register   Sign In
Setting a menu item to "selected"
#6

[eluser]maxo[/eluser]
Sneaky way I did it:

Code:
<div id="nav">
&lt;?php
$seg = $this->uri->segment(1) . "/";
$stuff['/'] = ""; $stuff['link1/'] = ""; $stuff['link2/'] = "";
$stuff[$seg] = array('class' => 'selected');
?&gt;
<ul>
<li>&lt;?php echo anchor('/', "Home page", $stuff['/']); ?&gt;</li>
<li>&lt;?php echo anchor('link1', "Link 1", $stuff['link1/']); ?&gt;</li>
<li>&lt;?php echo anchor('link2', "Link 2", $stuff['link2/']); ?&gt;</li>
</ul>


But I believe Ruby-on-rails can do this automagically. It would be awesome if there was an easier way with CodeIgniter (I especially hate having to define the array indexes as = "", just avoiding that above would be nice if anyone can think of a way...)


Messages In This Thread
Setting a menu item to "selected" - by El Forum - 06-16-2010, 02:16 PM
Setting a menu item to "selected" - by El Forum - 06-16-2010, 02:38 PM
Setting a menu item to "selected" - by El Forum - 06-16-2010, 02:39 PM
Setting a menu item to "selected" - by El Forum - 06-16-2010, 08:56 PM
Setting a menu item to "selected" - by El Forum - 06-25-2010, 03:04 PM
Setting a menu item to "selected" - by El Forum - 08-14-2011, 05:52 PM
Setting a menu item to "selected" - by El Forum - 04-14-2012, 03:25 PM
Setting a menu item to "selected" - by El Forum - 04-14-2012, 05:01 PM
Setting a menu item to "selected" - by El Forum - 04-14-2012, 05:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB