Zola Posted October 10, 2013 Share Posted October 10, 2013 (edited) Hey I have a menu in place that works well on a website I am building. I use a php include so that the menu is served up the same over all the pages, nice and easy for updates etc. I felt it was important to have an indicator on the selected menu item to reassure the user what page they are on. Heres a code snippet of how I did this this. Using the .selected class in CSS I simply changed the colour of the item. <ul class="menu"> <li><a href='index.php' <?php if( $page == 'index') echo 'class="selected"'?> ><span>Home</span></a></li> </ul> I have another sub menu on a few pages that categories some content (I want these items to be on 6-7 pages). How could I do the same thing as above for these? As you can see below, I already have a class name for these items, as I wanted them appear as a button I made. <a href="sub_item.php" class="icons_button"><i class="icon-tablet"> </i> Sub Item Example</a> Edited October 10, 2013 by Zola Quote Link to comment https://forums.phpfreaks.com/topic/282866-need-help-with-a-sub-menu-please/ Share on other sites More sharing options...
Solution cyberRobot Posted October 10, 2013 Solution Share Posted October 10, 2013 Have you tried doing something like this: <a href="sub_item.php" class="icons_button<?php if($page == 'index') echo ' selected'; ?>"><i class="icon-tablet"> </i> Sub Item Example</a> Quote Link to comment https://forums.phpfreaks.com/topic/282866-need-help-with-a-sub-menu-please/#findComment-1453431 Share on other sites More sharing options...
Zola Posted October 11, 2013 Author Share Posted October 11, 2013 That works well, thanks!! Dont know how I missed it. Much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/282866-need-help-with-a-sub-menu-please/#findComment-1453518 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.