How do you exclude certain elements from include pages?


#1

I’m working on a “bread crumbs” type link system that will appear at the top of my pages. For example, it might display something like this:

Home > World > North America > U.S. > Alaska

The primary code is in an include page and looks something like this:

[php]
echo '

GS Home >
’ . $seclink . ‘’ . $contlink . ‘’ . $natlink . ‘’ . $statelink . ‘’ . $myname . ’
[/php]

($sec, $cont, $nat and $state stand for Section, Continent, Nation and State.)

I put the corresponding echo functions in the head section of each page, with upper hierarchy pages getting less. For example, I only need $seclink on North America’s home page, while a state page (like Alaska) needs $seclink, $contlink and $natlink.

But I realized that life would be a lot simpler if I just stuck all the echo functions in another include page. The only problem is that now all four links show up on every single page.

So, to cut to the chase, what are some strategies I could use to exclude certain links from certain pages? For example, how would I bar $statelink from every “nation” page? How would I bar $natlink and $statelink from every continent page?

Thanks.

[php]
$seclink = ‘’ . $mysec . ’ > ';

$contlink = ‘’ . $mycont . ’ > ';

$natlink = ‘’ . $mynat . ’ > ';

$statelink = ‘’ . $mystate . ’ > ';

[/php]


#2

when using your a hrefs, always pass all the variable names you need. then in your include, simply just do a function to test if the variable has a value or not.

<?
echo '<div class="toplinks"><a href="/geosymbols/index.php">GS Home</a> &gt;';

if ($_GET[seclink]!="") {
 print $_GET[seclink]." >";
}

if ($_GET[natlink]!="") {
 print $_GET[natlink]." >";
}

if ($_GET[statelink]!="") {
 print $_GET[statelink]." >";
}

if ($_GET[myname]!="") {
 print "<span class="navhere">".$_GET[myname]."</span>";
}
?>

or something like that…

then call your script like so:
something.php?seclink=World&natlink=North%20America&statelink=California&myname=Test

output:

GS Home >World >North America >California >Test 

another example
something.php?seclink=World&natlink=North%20America&statelink=&myname=

GS Home >World >North America > 

then just have your pages fill in the variables in your href… hope that helps