EllisLab text mark
Advanced Search
     
Dynamic Menu with selected Link
Posted: 05 October 2012 10:18 AM   [ Ignore ]
Joined: 2012-10-05
5 posts

Hi,

I have a question how to figure out an dynamic menu.
Must be easy to create a simple array für the dynamic menu.

But I allthough wants to get a “selected” class when the link is on the same sitepage.

Like: Menuitem => Contact. When User has clicked the Link “Contact” and is on this “Contact-Site” the Code will post an extra “selected” class to the link.

Any Ideas?

Sorry about my “bad” english.

Best, Jens

 
Posted: 05 October 2012 05:57 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2011-10-25
62 posts

What I do is use the URI segments to match a menu item uri.
When a match is found you can set the selected class.

 
Posted: 09 October 2012 07:49 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-10-05
5 posts

Old answer about the question

So, I think (hope) that will do!

In the end I did it this way.
Looks not very genius, but works.

<ul id="navigation">
<
li<?php if (uri_string()==FALSE) echo ' class="selected"'?>><
href
="http://localhost/codeigniter/index.php">Home</a></li>
<
li<?php if (uri_string()==='about') echo ' class="selected"'?>><
href
="http://localhost/codeigniter/index.php/about/">About</a></li>
<
li<?php if (uri_string()==='impressum') echo ' class="selected"'?>><
href
="http://localhost/codeigniter/index.php/impressum/">Impressum</a></li>
<
li<?php if (uri_string()==='news') echo ' class="selected"'?>><
href
="http://localhost/codeigniter/index.php/news/">News</a></li>
<
li<?php if (uri_string()==='news/create') echo ' class="selected"'
?>><a href="http://localhost/codeigniter/index.php/news/create/">Create 
News
</a></li>
</
ul

If u know easier and better ways please write it down.

Kind regards,
Jens

 
Posted: 10 October 2012 04:07 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2011-10-25
62 posts

You found the answer but you are not using it?
Why?