Zola Posted October 10, 2013 Share Posted October 10, 2013 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> Link to comment https://forums.phpfreaks.com/topic/282866-need-help-with-a-sub-menu-please/ Share on other sites More sharing options...
cyberRobot Posted October 10, 2013 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> 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. 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
Archived
This topic is now archived and is closed to further replies.