0

Hi everyone! Thanks for reading my post.

I have 2 questions,

first I have a PHP site where it reads the pages from a folder and shows it in a php frame, for example the contact us page with the file name of contact.php will be shown as http://www.<DOMAIN>?page=contact. and when you go from one line to another the contact changes to the next file name (minus extension).

first question is: my navigation which is an include file has css hover effects and when you click on a link that link should have a different back ground colo (just like daniweb) (see how web development is purple and the rest grey) but how can I get it to do that?

2nd question is how can I add a breadcrumb? all pages comes up as index.php (Home), I am not sure how I can differentiate from the pages.

Thanks for all your help!

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by andy106
0

I'm not sure if you can use breadcrumbs with the way that you've got your site set up as the only way I've worked with them is that each crumb is a folder (i.e.: crumb1 >> crumb2 >> crumb3 >> CurrentPage). I could be wrong though.

I'm assuming the menu is part of the index page rather than in the included pages each time so you could add a simple if statement to determine what page you're on to keep it the same colour:

<li class="menu" <?php if($page == "contact"){echo "style=\"background-color: #ff00cd;\"";}?>><a href="index.php?page=contact">Contact</a></li>

What this does is add an extra style tag into the <li> if it's the current page which will overwrite the background colour of whatever the .menu class in the css file says to do.

I'm not sure how you have your menu coded so adjust as needed.

0

Hi Borzoi, thanks for your response, you if statement above didn't work, I wrote a simple script to show me the current page and it is showing all pages to index.php, so all other pages are being read as index.php, and I think that may be why your solution didn't work, i guess the question is how do we separate the pages? would this be where case comes in play?

0

so what I ended up doing was to write a short function to output the full path of the page, and then I used the IF statement you gave me so here is how it looks like:

<?php if(myfullpath() == "http://domainname.com/?page=contact"){echo "hover";}?>

just FYI hover is a css class. this is not the best option, but it works, if there are any better solutions please feel free to let me know.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.