twothink02 Posted January 5, 2016 Share Posted January 5, 2016 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"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:php="http://php.net/xsl" lang="en"> <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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/300183-customizing-menu-on-headerphp-for-inner-pages/ Share on other sites More sharing options...
requinix Posted January 5, 2016 Share Posted January 5, 2016 Then rearrange the code so you determine the $mainNav before the header gets included. Quote Link to comment https://forums.phpfreaks.com/topic/300183-customizing-menu-on-headerphp-for-inner-pages/#findComment-1529169 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.