Hi, I've put my navigation in a php script so i only have to update it once when the site is up and running, but I want it to recognise which page its on and show a different background image/font for that page in the Navigation. site is at http://www.mattvalentine.co.uk/norcross/index.php i know if it wasn't in the php i could just add a class to whichever page it was on at that point but want to keep my code tidy and save time in the future. PLEASE HELP ! First attempt at PHP ! ta
i'd suggest to keep SEO in mind and make map array (with google friendly navigation), to load subcontent within your pages. http://www.mattvalentine.co.uk/norcross/?q=my-content
Use this piece of code in the php file, where links are saved (and is included inside other site files, I use same trick). if($_SERVER['PHP_SELF']=="some_file_name.php") { $background="img1.jpg"; } elseif(...) { ... } ... If guess, you got my point. If you need more clarification, PM me.
A twist on this that will save you coding space if you have a lot of pages is: $background = str_replace("php", "jpg", $_SERVER['PHP_SELF']); $background = str_replace("/", "", $background); PHP: The second part may or may not be necessary, depending on how you're doing it. Now just save your backgrounds as page_name.jpg and badabing.
The easiest way is just to define a page variable at the top of the page. E.g <?php $page = "Home"; include("header.php"); ?> Code (markup): Then, in the header file, check if the page is equal to the page variable and add a class if it is. You should put all your menu items in an array to make things easier. E.g $menu_items = array( "Home" => "link to home", "About" => "link to about" ) foreach($menu_items as $name=>$link){ if($page == $name){ // this is the item for the current page } else { // regular item } } Code (markup):