menu css

By Maurice - October 14, 2010

Any one got a smart way to see what page is active so i can tel my css/class menu that it must be active???
-------------------------------------------

Dropmonkey.nl

Re: [Maurice] menu css

By Chris - October 14, 2010

Hi Maurice,

I usually use preg_match() to check the URL path, like this:

<ul>
<li><a href="/foo/" class="<?php echo preg_match('|/foo|', $_SERVER['SCRIPT_NAME']) ? 'active' : 'inactive' ?>">Foo</a></li>
<li><a href="/bar/" class="<?php echo preg_match('|/bar|', $_SERVER['SCRIPT_NAME']) ? 'active' : 'inactive' ?>">Bar</a></li>
<li><a href="/baaz/" class="<?php echo preg_match('|/baaz|', $_SERVER['SCRIPT_NAME']) ? 'active' : 'inactive' ?>">Baaz</a></li>
<li><a href="/quux/" class="<?php echo preg_match('|/quux|', $_SERVER['SCRIPT_NAME']) ? 'active' : 'inactive' ?>">Quux</a></li>
</ul>


Does that help? Please let me know if you have any questions.
All the best,
Chris

Re: [chris] menu css

By Maurice - October 14, 2010

cool

great this is super...

do u also have a solution for breadcrumbs hahahah
-------------------------------------------

Dropmonkey.nl