Welcome Guest, Not a member yet? Register   Sign In
Dynamic Menu with selected Link
#1

[eluser]MrMahi[/eluser]
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
#2

[eluser]GrahamDj28[/eluser]
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.
#3

[eluser]MrMahi[/eluser]
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.

Code:
<ul id="navigation">
<li&lt;?php if (uri_string()==FALSE) echo ' class="selected"'; ?&gt;><a
href="http://localhost/codeigniter/index.php">Home</a></li>
<li&lt;?php if (uri_string()==='about') echo ' class="selected"'; ?&gt;><a
href="http://localhost/codeigniter/index.php/about/">About</a></li>
<li&lt;?php if (uri_string()==='impressum') echo ' class="selected"'; ?&gt;><a
href="http://localhost/codeigniter/index.php/impressum/">Impressum</a></li>
<li&lt;?php if (uri_string()==='news') echo ' class="selected"'; ?&gt;><a
href="http://localhost/codeigniter/index.php/news/">News</a></li>
<li&lt;?php if (uri_string()==='news/create') echo ' class="selected"';
?&gt;><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
#4

[eluser]GrahamDj28[/eluser]
You found the answer but you are not using it?
Why?




Theme © iAndrew 2016 - Forum software by © MyBB