barrycorrigan Posted August 18, 2011 Share Posted August 18, 2011 Hi Everyone, I am creating a website with no CMS which is proving a bit difficult when I started thinking about how to do sub navigation for all the pages from one include file. So I came up with a system that worked by using a $currentPage variable then on every page I will give that page a $currentPage name. But on some of the pages I need two names I've came up with this but I don't no if it's right. <?php $currentPage = ('containment_systems' && 'download_booths'); require_once '_inc/sidenav.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/245096-php-sub-navigation-help/ Share on other sites More sharing options...
MasterACE14 Posted August 18, 2011 Share Posted August 18, 2011 you mean... ? <?php switch ($currentPage) { case 'containment_systems': require_once('containment_systems_inc/sidenav.php'); break; case 'download_booths': require_once('download_booths_inc/sidenav.php'); break; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/245096-php-sub-navigation-help/#findComment-1258929 Share on other sites More sharing options...
barrycorrigan Posted August 18, 2011 Author Share Posted August 18, 2011 Hi MasterACE14, Na that didn't work. Here is what I have to date so I have a subnavigation like so: <div id="sidenav"><!-- Open Sidenav --> <h3>In this section</h3> <ul> <li><a href="containment_strategy.php" <?php if ($currentPage == 'containment_strategy') {echo 'class="selected"';} ?>>Containment Strategy</a></li> <li><a href="containment_systems.php" <?php if ($currentPage == 'containment_systems') {echo 'class="selected"';} ?>>Containment Systems</a> <?php if ($currentPage == 'containment_systems') { ?> <ul> <li><a href="downflow_booths.php" <?php if ($currentPage == 'download_booths') {echo 'class="selected"';} ?>>Downflow Booths</a> <?php if ($currentPage == 'download_booths') { echo ' <ul> <li><a href="sampling_booth.php">Sampling Booth</a></li> <li><a href="dispensing_booth.php">Dispensing Booth</a></li> <li><a href="charging_booth.php">Charging Booth</a></li> <li><a href="quadraflow.php">Quadraflow</a></li> <li><a href="lab_bench.php">Lab Bench</a></li> </ul> ';} ?> </li> <li><a href="high_containment_screen.php">High Containment Screen</a></li> <li><a href="containment_isolators.php">Containment Isolators</a></li> <li><a href="pack_off_and_process.php">Pack off and Process</a></li> <li><a href="glassware_and_kilolab.php">Glassware and KiloLab</a></li> <li><a href="low_cost_isolators">Low Cost Isolators</a></li> </ul> <?php ;} ?> </li> <li><a href="aseptic_systems.php" <?php if ($currentPage == 'aseptic_systems') {echo 'class="selected"';} ?>>Aseptic Systems</a></li> <li><a href="facilities.php" <?php if ($currentPage == 'facilities') {echo 'class="selected"';} ?>>Facilities</a></li> <li><a href="after_market.php" <?php if ($currentPage == 'after_market') {echo 'class="selected"';} ?>>After Market</a></li> </ul> </div><!-- Close Sidenav --> Then the $currentPage code on each page to display which nav <?php $currentPage = ("download_booths"&&"containment_systems"); require_once '_inc/sidenav.php'; ?> So if im on Download_booths page I need the $currentPage variable to display download_booths and containment_systems. at the minute this works but it's making all the $currentPage variables a selected class Please help anybody :-) Regards Barry Quote Link to comment https://forums.phpfreaks.com/topic/245096-php-sub-navigation-help/#findComment-1258956 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.