Notice: Undefined index: testing in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/webdesign/4_Physical_Design/Coding_HTML/Coding_HTML_Current_Page/Current_Page.html on line 127

Notice: Undefined variable: docRoot_secure in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/webdesign/4_Physical_Design/Coding_HTML/Coding_HTML_Current_Page/Current_Page.html on line 143

Training

"Winners make choices,
losers make excuses.
"
Decide to be a Winner!!!!

±Arrows Getting Started

± Phase 1
Planning

± Website Tools

± Phase 3
Conceptual Design

± Helpful Information

± Phase 4
Physical Design

± Phase 5
Testing

± Phase 6
Implement and Market Website

± Other Web Development Items

± Multimedia

± Useful Utilities

± Programming

± Advanced Programming

± Microsoft Office Products

± Computer Maintenance

± Other


Web Design

NOTE: This is a collection of information and links collected over the years that might provide useful information. A Safer Company LLC does not guarantee, endorse or approve any of these links or their scripts. Use these links to other websites at your own risk.


Notice: Undefined variable: message in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/webdesign/Templates/code/dir_listing_enhanced.php on line 67

Notice: Undefined variable: message in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/webdesign/Templates/code/dir_listing_enhanced.php on line 72

Warning: Use of undefined constant r - assumed 'r' (this will throw an Error in a future version of PHP) in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/code/F_get_page_title_Enh.php on line 28

Notice: Undefined variable: print_file_data in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/webdesign/Templates/code/dir_listing_enhanced.php on line 127

Warning: Use of undefined constant r - assumed 'r' (this will throw an Error in a future version of PHP) in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/code/F_get_page_title_Enh.php on line 28

Warning: Use of undefined constant r - assumed 'r' (this will throw an Error in a future version of PHP) in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/code/F_get_page_title_Enh.php on line 28

Warning: Use of undefined constant r - assumed 'r' (this will throw an Error in a future version of PHP) in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/code/F_get_page_title_Enh.php on line 28

Notice: Undefined variable: print_folder_data in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/webdesign/Templates/code/dir_listing_enhanced.php on line 160

Notice: Undefined variable: message in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/webdesign/Templates/code/WebDesign_toc.php on line 12

Notice: Undefined variable: message in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/webdesign/4_Physical_Design/Coding_HTML/Coding_HTML_Current_Page/Current_Page.html on line 247

Current Page with PHP and CSS

It is important to let your visitors know what page they are currently viewing.

You can always change the HTML code on each page to show which page is the current page, but this method can be a real headache to code and maintain. It is much easier to use programming to determine the current page. There are many program languages that can be used to determine the current page like PHP, Perl, ASP, etc. I like to use PHP for several reasons.

  1. PHP is a free program language and works on LYNUX operating systems.
  2. PHP can be embedded in the HTML code.
  3. PHP is easy to learn.

Step 1:

Create 3 images to use for backgrounds for your navigation links. The images below are 30px (width) X 25px (height).

  • bullet.png - This is the navigation link
  • mouseover.png - This image will display when you mouse over a link
  • current.png - This image will display beside the navigation link to the current page.

Step 2:

  1. Set up your navigation list using unordered list <ul></ul>.
    • Home
    • Product 1
    • Product 2
  2. Wrap the list in a <div id="sidemenu"> tag.

Copy and paste this code into your HTML

Step 3:

Add the links to your navigation.

  • Home
  • Product 1
  • Product 2

Copy and paste this code into your HTML

Step 4:

  1. Create the CSS for the <div id="sidemenu">
  2. Create a CSS class to display a different background for the current page. Name the class: current

Step 5:

Baiscs of PHP

  • PHP code must start with <?php and end with ?> and it must be placed in the code view if using Dreamweaver.
  • PHP is rendered on the web hosting server.
  • You will not see the PHP code when you view the source code in the browser.
  • You must put the code on the web hosting server and view in the browser to see the results of the PHP code.

This is an example of a simple PHP script to determine the current file name. Copy the code and place it on your webpage in the <body> and before the navigation links.

  • PHP code to get the current path and file

    You should see a line of code similiar to:
    currentFile = /4_Physical_Design/Coding_HTML/Coding_HTML_Current_Page/Current_Page.html
  • PHP code to get hte file name only

    You should see a line of code similiar to:
    currentFile = Current_Page.html

NOTE: Your file may have to end with the extension .php depending on how your web hosting server is set up.

Step 6:

Once you have PHP code working to determine the current file, then you can create a line of PHP code to print class for the current page.

  1. Start by setting up a regular link:
    <a href="index.html">Home</a>
  2. Add a class="current" to display the link
    <a href="index.html" class="current">Home</a>
  3. Test and make sure the current link displays your current image
  4. Add the PHP code to the link to let PHP determine the current page
    <a href="index.html" <?php if ($currentpage=="index.html") {echo 'class="current"';} ?> >Home</a>
  5. Test your page to make sure it is working correctly and the current page has a different background image displayed.

Step 7:

Make sure you test each step.

top of page


Warning: Use of undefined constant PHP_SELF - assumed 'PHP_SELF' (this will throw an Error in a future version of PHP) in /hermes/walnacweb03/walnacweb03af/b1896/as.asaferco/webdesign/4_Physical_Design/Coding_HTML/Coding_HTML_Current_Page/Current_Page.html on line 409

Page last updated: May 31, 2012 14:27 PM

It is all about:
Content and Navigation...

Web Site by: A Safer Company LLC