Jump to content

customizing menu on header.php for inner pages


twothink02

Recommended Posts

I have a basic tab menu that is minimally customized depending on what page is viewed e.g. Page A is viewed so the Page A menu tab has a white background. All other tabs have a tan background. I'm trying to do this with a header.php, page.php, and a .css. So if the Title of the page.php is the same as one of the tabs then that tab should have a white background.

 

My code doesn't work because I can't push the $mainNav variable on the page.php back to the header.php. Not sure that's even possible or maybe I'm just doing this a completely silly way. Little help. Thanks. 

 

 

 

Header.php:

 

<?php
$menu[0] = "A";   
$menu[1] = "B";
$arrlength = count($menu);     
?>
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<head xmlns="">
<meta STUFF>  
 <title>MY <?php echo $title; ?></title>
</head>
 
<body class="lo_generic_auto4">
 <div id="body">
    <div id="wrapper" class="navpos_north">
     <div xmlns="" id="navigation" class="tglsty_arrow sub_dynamic">
      <ul id="mainNav" role="navigation">
       <li class="<?php echo $mainNav; ?>" style="z-index:8"><a href="A.html"><?php echo $menu[0]; ?></a></li> 
       <li class="<?php echo $mainNav; ?>" style="z-index:7"><a href="B.html"><?php echo $menu[1]; ?></a></li> 
      </ul>
     </div>
 
<!-- end header -->
 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
Page.php:
 
<?php
$title = "Home";                  
$arrlength = count($menu);     
include "header.php";                 
?>
 
 
 
<?php
 
for($x = 0; $x < $arrlength; $x++) {
 
 
var_dump($title);
var_dump($menu[$x]);
 
 
if ($title == $menu[$x]){
       $mainNav = "mainNav active";
       echo "if " . $mainNav . $title . $menu[$x] ." <br /><br />";
 
else {
     $mainNav = "mainNav";
     echo "else " . $mainNav . $title . $menu[$x] ." <br /><br />";
}
 
}
?>
 
<!-- end page content -->
 
<?php
include "footer.php";               
?>
 
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.