Help - Search - Members - Calendar
Full Version: If Statements
Weborum Webmaster Forum > TUTORIAL ARCHIVE - tutorials & scripts to save you scouring the internet. Please feel free to add your own. > PHP Tutorials & scripts
Gandalf
Hi,

I would like the following line to dynamically change depending on page.

You are here: Contact Us > Webmaster

Main Menu: Contact Us
Sub Page: Webmaster

Contact Us will have sub menus as well and will have this order in a mouseover pulldown menu:

Link One
Link Two
Link Two Sub
Link Three
Link Four
Link Four Sub
Link Four Sub-sub
Link Five


ACTUALLY, now that I think about this, we could really simplify things a great deal if we would simply have the script read the page.php name and echo it accordingly.

So though webmaster.php is a sub link under the Contact Us Menu choice it doesn't matter as the code would echo simply:

You are here: Contact Us > Webmaster


How do we make this simply code work?

Thanks,
Gändälf
biggrin.gif
karinne
you could create a function that displays the name and in each page call that function... something like

PHP

function breadcrumbs($name) {
  echo 'You are here: Contact Us > '.$name;
}


and when you call the function you do
PHP

breadcrumbs('Webmaster');


something like that?!?
Gandalf
Yeah that would be the concept I am going for, but being that I'm new to PHP I don't know how to write it. Tell me once (or maybe twice) to where I understand it and that will be enough...who am I kidding? you'll probably have to explain a few times. lol

Anyway, the function we'll call, youarehere.

function youarehere($name) {
echo 'You are here: Contact Us > '.$name;
}

youarehere('Webmaster');

Now, how do we get $name to read the page's url?

karinne
hmmm... i forgot you wanted to do it that way... mmm... the way i did it you'd just write what you'd want to see there in the youarehere('....');
Gandalf
Okay, I think I need to explain this differently. I understand what you are saying, but that's basically no more different then simply writing [ You are here: Contact Us > Webmaster ] in HTML on every page.

I would like for it to do the work to put it bluntly. If it's the index.php it needs to echo Home; if it's the contact.php page it should echo Contact, etc.

Does that make sense?
Willy Duitt
http://www.google.com/search?q=php+breadcrumb+script
Gandalf
Thanks all.

Just got back from the bookstore. I went over there and picked up a copy of PHP Pocket Reference. Also noticed there was a second edition of the CSS Pocket Reference for CSS2 as well, so I'll have to pick that one up too.

Happy Holidays!
Gändälf
biggrin.gif

P.s. This doesn't mean I'm going to quit posting; matter of fact, it will probably even raise more questions to post. =P
Gandalf
Hi again,

Yeah...we all knew I would be back with more questions. tongue.gif

So I check the link out that Willy Duitt posted and found this site: http://www.baskettcase.com/classes/breadcrumb/

One question to this whole thing though; this breadcrumb link is in reference to DIR's and on the site I'm working on all of the PHP pages viewed by the public are in the www directory. So, that eliminates DIR's...obviously.

Now on this site there will be mouse-over pulldown menus choices with multiple sub menu as I described on the first post of this thread. So since all of these pages are in the same directory this breadcrumb function is not going to help much as I see it, because the only hiarchical page organization here is merely in the menu when you mouse over it.

So would it not prove beneficial for me to simply use the echo function on every page to display the [ You are here: Contact > Webmaster ] feature?

G
biggrin.gif
Gandalf
Well, Christmas holidays are over and I am back.

Once again I am replying to this thread to keep it fresh hoping someone will see it and be able to reply with a solution.

Please read the above post and see what you think or suggestion an alternative.

Thanks,
Gändälf
biggrin.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.