Jump to content

Help with navigation


dc_jt

Recommended Posts

Hi Ive got a navigation which has 3 tiers. I want to show certain tiers depending on what page I am on.

 

1. Our Projects

          Category Name

                  Project Name

          Category Two Name

                  Project Two Name

                  Project Three Name

 

etc etc...

 

The idea is that at first only 'Our Projects' is shown.

 

When you click this and go to the /projects/ page, the 'Category Name' and 'Category Name Two' will appear.

 

When you click a category e.g 'Category Name' this will take you to /projects/our-projects.php?iCategoryId=1 and the projects for this category will appear (in this case 'Project Name').

 

When you click a project e.g. Project Name, you are taken to the projects/centre.php?iCentresId=1 page and the categories and projects for this category are still shown.

 

The way I have done it works, however when I click the actual project, it hides the project in the dropdown.

 

Hope all this makes sense, I have tried to describe as best as I could.

 

Please see below for what Ive done so far.

 

$d=explode("/",$_SERVER[sCRIPT_NAME]);
$file=($d [1]);
$file2 = ($_SERVER[sCRIPT_NAME]);
$url = $_SERVER['REQUEST_URI'];

<li><a href="/projects/" accesskey="N">Our Projects</a>
        <?php if($file == 'projects'){?>
        <ul>

        <?php
			while ($oCategories = mysql_fetch_object($rCategories))
			{?>
      	<li><a href="/projects/our-projects.php?iCategoryId=<?=$oCategories->category_id?>" accesskey="P"><?=$oCategories->category?></a>
        	
      	<?php 
                	$rCentresArticles = $oTblCentres->GetArticles($iStart, 500, $oCategories->category_id);
                	if($url == '/projects/our-projects.php?iCategoryId='.$oCategories->category_id.''){?>
      			<ul>

                	<?php
				while ($oCentresArticle = mysql_fetch_object($rCentresArticles))
				{
					if($url == '/projects/centre.php?iCentresId='.$oCentresArticle->centres_id.'' || $url == '/projects/our-projects.php?iCategoryId='.$oCategories->category_id.''){?>
				<li><a href="/projects/centre.php?iCentresId=<?=$oCentresArticle->centres_id ?>"><?=$oCentresArticle->title?></a></li>
				<?php }?>
				<?php }?>
        	</ul>
        	<?php }?>
        </li>
        <?php }?>
        </ul>
        <?php }?>

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/100609-help-with-navigation/
Share on other sites

Update :

I now have the following which works, although when I click on a project it only shows that project and not all projects for that category in the nav.

 

Any ideas of how I can change this to still show all projects for the category. I know its because Ive put

($url == '/projects/centre.php?iCentresId='.$oCentresArticle->centres_id

but I dont know how else to do it?

 

Thanks

 

<li><a href="/projects/" accesskey="N">Our Projects</a>
        <?php if($file == 'projects'){?>
        <ul>

        <?php
			while ($oCategories = mysql_fetch_object($rCategories))
			{?>
      	<li><a href="/projects/our-projects.php?iCategoryId=<?=$oCategories->category_id?>" accesskey="P"><?=$oCategories->category?></a>
        	
      	<?php 
                	$rCentresArticles = $oTblCentres->GetArticles($iStart, 500, $oCategories->category_id);

                	if($url == '/projects/our-projects.php?iCategoryId='.$oCategories->category_id.'' || $file2 == '/projects/centre.php'){?>
      		

                	<?php
                	$iCount=0;
				while ($oCentresArticle = mysql_fetch_object($rCentresArticles))
				{?>
				<?php if($url == '/projects/centre.php?iCentresId='.$oCentresArticle->centres_id || $url == '/projects/our-projects.php?iCategoryId='.$oCategories->category_id.''){?>
				<? 
				$iCount++;
				if ($iCount == '1'){
					echo "<ul>";
				}?>
				<li><a href="/projects/centre.php?iCentresId=<?=$oCentresArticle->centres_id ?>"><?=$oCentresArticle->title?></a></li>
				<?php }?>
				<?php }?>
				<? if ($iCount >= '1'){
					echo "</ul>";	
				}?>

        	<?php }?>

        </li>
        <?php }?>
        </ul>
        <?php }?>
        
        </li>

Link to comment
https://forums.phpfreaks.com/topic/100609-help-with-navigation/#findComment-514563
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.