PHP "Bread Crumbs" links and Excluding Include Ele


#1

I’ve had an extremely tough time getting a handle on relative versus absolute links and “bread crumbs” link systems, so bear with me if my description of my problem is a bit long-winded. I’ll make it as brief as I can!

Let me start with a “bread crumbs” style link sequence:

[php]

<?php $todayDate = date("m-d-Y"); echo '
GeoWorld Home > ' . $seclink . '' . $contlink . '' . $natlink . '' . $statelink . '' . $myname . '
' ?>

[/php]

$sec, $cont, $nat and $state refer to Section (World), Continent, Nation and State.

Below are some related echo sections from the page’s head section:

[php]

<?php $seg = '../../../'; $myname = 'Afghanistan'; $mycode = 'af'; $mynat = '' . $myname . ''; $nat = '' . $mycode . ''; $mycont = 'Eurasia (Asia)'; $cont = 'eurasia'; $contlink = '' . $mycont . ' > '; $mysec = 'World'; $sec = 'world'; $seclink = '' . $mysec . ' > '; include ($seg."a1/inc/head.php") ?>

[/php]

When you plug it all in, the visitor sees this at the top of the page:

GeoWorld Home > World > Eurasia > Afghanistan

Every word is linked to the proper page except for the last word.

This system works fine, but I want to refine and improve it. Consider this element:

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

It’s fairly long, plus the …/ sequence URL won’t work in all pages. In some pages, I have to change it to …/…/ or …/…/…/.

Rather than insert these links on every single page and tweak the segments (…/), it would be so much easier if I could just insert standardized links in an include page.

This is what I came up with:

[php]

<?php $seclink = '' . $mysec . ' > '; $contlink = '' . $mycont . ' > '; $natlink = '' . $mynat . ' > '; $statelink = '' . $mystate . ' > '; ?>

[/php]

I guess you’d call these links relative, but the only variable is
$seg = ‘…/…/…/’;, which I still have to tweak on every target page. But that’s no big deal. It works beautifully, except for one problem.

Since all four links (Section, Continent, Nation and State) are now in a page that’s included in every page on my site, visitors see ALL the links. Thus, someone visiting the United States home page might see something like this:

Home > North America > U.S. > State

So what I’m FINALLY getting around to asking is how do I EXCLUDE links? Let’s say I’m on the North America home page, and I don’t want to see the links to U.S. or States - the last two links in the included code below. How can I block them?

[php]

<?php $seclink = '' . $mysec . ' > '; $contlink = '' . $mycont . ' > '; $natlink = '' . $mynat . ' > '; $statelink = '' . $mystate . ' > '; ?>

[/php]

Thanks, and sorry for the rambling explanation!


#2

Why don’t you replace “$seg” with “http://www.example.com/” ? Make all your links absolute. You may also might be able to get around it with a tag in your html.

To not display links, you should check to see if they exist. If you’re on a continent page, you shouldn’t have any country codes set, so check for it and don’t display the links.

You also might want to check out the (slightly outdated) tutorial at http://www.phpbuilder.com/columns/tim20 … hp3?aid=20 Sounds like what you’re trying to do. Make sure you understand it completely, and not just copy the code.