VTJ Posted April 4, 2011 Share Posted April 4, 2011 Hi, First of all, this is not a spam. Someone with the username Pikachu2000 removed it thinking it was a spam so now I have to post it again. I really need you help fixing this problem. Anyway, I'm building a site where I used a "php include once" for the navigation menu. I was able to show the active pages when they don't have sub pages but I can't seem to show the active sub pages. I've been trying for days and nothing I try seems to work! I'm sure some people have asked this before but I can't find any forums that describe how to do this with sub navs rather then just the main nav buttons. The coding is below along with a link to one of the sub pages in the site I'm working on. The problem is with the sub pages under "Our Coffee Farm". Thanks for reading my post. Website Link: http://vanessajohodesigns.com/sarpa/the_farm/plantation.php before DOCTYPE: <?php $thisPage="The Plantation"; ?> after body tag: <?php include_once("../includes/nav.php");?> nav.php include once file: <div class="arrowsidemenu"> <div<?php if ($thisPage=="Home") echo " class=\"active\""; ?>> <a href="../index.php">Home</a></span></div> <div class="menuheaders"><a>Our Coffee Farm</a></div> <ul class="menucontents"> <li<?php if ($thisPage=="The Plantation") echo " class=\"active\""; ?>><a href="plantation.php">The Plantation</a></li> <li<?php if ($thisPage=="Blooming & Harvest") echo " class=\"active\""; ?>><a href="bloom_harvest.php">Blooming & Harvest</a></li> <li<?php if ($thisPage=="Coffee Processing") echo " class=\"active\""; ?>><a href="processing.php">Coffee Processing</a></li> </ul> <div<?php if ($thisPage=="About Us") echo " class=\"active\""; ?>> <a href="../about_us.php">About Us</a></div> <div<?php if ($thisPage=="Rainforest Alliance") echo " class=\"active\""; ?>> <a href="../rainforest_alliance.php">Rainforest Alliance</a></div> <div<?php if ($thisPage=="Social Commitment") echo " class=\"active\""; ?>> <a href="../social_commitment.php">Social Commitment</a></div> <div<?php if ($thisPage=="News & Events") echo " class=\"active\""; ?>> <a href="../news_events.php">News & Events</a></div> <div<?php if ($thisPage=="Web Cameras") echo " class=\"active\""; ?>> <a href="../webcams.php">Web Cameras</a></div> <div<?php if ($thisPage=="Photo Gallery") echo " class=\"active\""; ?>> <a href="../gallery.php">Photo Gallery</a></div> <div<?php if ($thisPage=="Contact Us") echo " class=\"active\""; ?>> <a href="../contact_us.php">Contact Us</a></div> <!--end .arrowsidemenu --></div> Quote Link to comment https://forums.phpfreaks.com/topic/232668-php-menu-active-button-for-sub-navs/ Share on other sites More sharing options...
dcro2 Posted April 4, 2011 Share Posted April 4, 2011 This doesn't really have much to do with PHP because you're using some kind of javascript toolkit for menus. When the page loads, it sets the menucontents list to be hidden (style="display:none"). You could try overriding it by setting style="display: block" in the php, but I don't know if the javascript would still override it. So try this: <div class="menuheaders"><a>Our Coffee Farm</a></div> <ul class="menucontents"<?php if($thisPage=="The Plantation"||$thisPage=="Blooming & Harvest"||$thisPage=="Coffee Processing") echo " style=\"display: block\""; ?>> Quote Link to comment https://forums.phpfreaks.com/topic/232668-php-menu-active-button-for-sub-navs/#findComment-1196704 Share on other sites More sharing options...
VTJ Posted April 4, 2011 Author Share Posted April 4, 2011 Hi dcro2, Thanks for your post. The coding you sent me didn't work but you were completely right about it having to do with the javascript rather then the PHP. It was already on display:block. The problem was that some of the javascript coding had to be placed internally rather then on a separate js file because of another js file linking to it. Also I had to use <span<?php if ($thisPage=="The Plantation") echo " class=\"active\""; ?>></span> tags on the sub navs. Woo hoo!!! I'm excited I kept thinking it was the PHP but it wasn't. Thanks again!!! Quote Link to comment https://forums.phpfreaks.com/topic/232668-php-menu-active-button-for-sub-navs/#findComment-1196754 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.