menu css

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

Re: [Maurice] menu css

By Chris - October 14, 2010

Hi Maurice,

Glad to help! :)

I find I usually have to hardcode breadcrumbs.
All the best,
Chris