Welcome to Dream.In.Code
Become a PHP Expert!

Join 149,882 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,335 people online right now. Registration is fast and FREE... Join Now!




Using PHP to highlight current item in menu

 
Reply to this topicStart new topic

Using PHP to highlight current item in menu

lance
31 Jan, 2007 - 10:44 PM
Post #1

New D.I.C Head
*

Joined: 30 Jan, 2007
Posts: 43


My Contributions
Now I have this dropdown menu in CSS & PHP, The trick will be to making the menu item STAY the color (based on the area you're in - somehow, it would need to know the architecture of the site - pulling from the URL to know when to KEEP the menu item highlighted.

Is there any way using PHP to determine the current page and highlight the respective menu item.

CODE
<div class="menu">
<ul>
<li><a href="<?php echo tep_href_link(FILENAME_ALL; ?>" class="hide"><?php echo ONE_OUR; ?></a>

<!--[if lte IE 6]>
<a href="<?php echo tep_href_link(FILENAME_ALL); ?>"><?php echo ONE_OUR; ?>
<table><tr><td>
<![endif]-->

    <ul>
    <li><a href="<?php echo tep_href_link('index.php', 'cPath=21'); ?>"><?php echo ONE_MENU; ?></a></li>
    <li><a href="<?php echo tep_href_link('index.php', 'cPath=26'); ?>"><?php echo ONE_GREEN; ?></a></li>
    <li><a href="<?php echo tep_href_link('index.php', 'cPath=25'); ?>"><?php echo ONE_BLACK; ?></a></li>
    <li><a href="<?php echo tep_href_link('index.php', 'cPath=22'); ?>"><?php echo ONE_WHITE; ?></a></li>
    <li><a href="<?php echo tep_href_link('index.php', 'cPath=24'); ?>"><?php echo ONE_FLAVOURED; ?></a></li>
    <li><a href="<?php echo tep_href_link('index.php', 'cPath=23'); ?>"><?php echo ONE_BAGS; ?></a></li>
    <li><a href="<?php echo tep_href_link('index.php', 'cPath=27'); ?>"><?php echo ONE_MIXED; ?></a></li>
    
    </ul>

<!--[if lte IE 6]>
</td></tr></table>
</a>
<![endif]-->

</li>


This post has been edited by lance: 1 Feb, 2007 - 02:05 AM
User is offlineProfile CardPM
+Quote Post

capty99
RE: Using PHP To Highlight Current Item In Menu
1 Feb, 2007 - 02:21 AM
Post #2

the real kya
Group Icon

Joined: 26 Apr, 2001
Posts: 9,253



Thanked: 16 times
Dream Kudos: 550
My Contributions
im sure there is a better way to do this but real quick and dirty send an id with the link so http://yoursite.com?id=#

and then for each link check if 'id' == #, then highlight link

REAL dirty.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 12:00PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month