Jump to content

PHP Menu "Active" button for sub navs


VTJ

Recommended Posts

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>

 

Link to comment
Share on other sites

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\""; ?>>

Link to comment
Share on other sites

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 :D I kept thinking it was the PHP but it wasn't. Thanks again!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.