Jump to content

PHP sub navigation help


barrycorrigan

Recommended Posts

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'; ?>

Link to comment
Share on other sites

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;
}
?>

Link to comment
Share on other sites

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

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.