jacchops Posted May 1, 2007 Share Posted May 1, 2007 Please forgive the ignorance; I am new to php. Could someone please tell me if it possible to do the following with php (or any other server-side scripts): Say you have a left menu that stays the same on every page within in your site. Obviously you would make this menu a template or library item, so that when you edit one version, all the others are updated. Let's say the left menu is the following: Page_1 Page_2 Page_3 Now, when I am viewing Page_1, I want the "Page_1" text in the left menu to be red, so that the viewer knows what page they are on. When I click on the left menu link for "Page_2", then I want the "Page_1" text to go back to black and the "Page_2" text to be red. Can it be done? Quote Link to comment https://forums.phpfreaks.com/topic/49521-how-to-change-template-menu-link-text-color-for-page-currently-viewed/ Share on other sites More sharing options...
boo_lolly Posted May 1, 2007 Share Posted May 1, 2007 you can do this by hard-coding the HTML, you can do this with javascript, and you can do it in php. we need to know more info to help you do it in php. but an example would be: if($_SERVER['php_self'] == 'Page_1'){ change color; } Quote Link to comment https://forums.phpfreaks.com/topic/49521-how-to-change-template-menu-link-text-color-for-page-currently-viewed/#findComment-242724 Share on other sites More sharing options...
jacchops Posted May 10, 2007 Author Share Posted May 10, 2007 Where would this php script go? Quote Link to comment https://forums.phpfreaks.com/topic/49521-how-to-change-template-menu-link-text-color-for-page-currently-viewed/#findComment-249425 Share on other sites More sharing options...
jacchops Posted May 10, 2007 Author Share Posted May 10, 2007 Here is so more info to help explain the problem. Let's say I have a website with 3 html pages: Home, About Me, Images. There is an identical menu at the top of each of these pages that looks like this: Home | About Me | Images When you click on "Home", it brings you to home.html, when you click on "About Me", it brings you to aboutme.html, etc. Since this navigation menu is the same on every page, I have made it a library (or template) item. So that if I open the template and change the text "Home" to "Welcome", then when I save it, all 3 of my pages will automatically be updated with the new menu: Welcome | About Me | Images When I am viewing the home.html page, I want the text "Welcome" in the navigation menu on the top of the page to be bold and red. When I click on "About Me" and go to the aboutme.html, I want the "Welcome" text to go back to it's original size and color and "About Me" to be bold and red. I'd like to do this with a server-side script so that no browser plug-ins are required to view. And I also want to keep my menu as a template, as it frequently changes. Quote Link to comment https://forums.phpfreaks.com/topic/49521-how-to-change-template-menu-link-text-color-for-page-currently-viewed/#findComment-249428 Share on other sites More sharing options...
triphis Posted May 10, 2007 Share Posted May 10, 2007 boo_lolly gave you all the code you need. first off, your pages should PROBABLY be .php not .html, unless your server parses PHP on .html extension pages.... then, use the code boo gave you right in front of the text, but after the link... if that if statement is true, it will change the font color. and you can add <b> there too. if that statement is false (ie, that page isnt the current page) the text will be displayed exactly as your CSS or page settings want Quote Link to comment https://forums.phpfreaks.com/topic/49521-how-to-change-template-menu-link-text-color-for-page-currently-viewed/#findComment-249431 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.