Zend - The PHP Company




Menus & Navigation

Add Code


Navigation Based On Directory Structure  

Type: code fragment
Added by: whatashocker
Entered: 07/02/2002
Last modified: 02/12/2001
Rating: - (fewer than 3 votes)
Views: 8693
Generate a directory structure link at the top of each page. Allows you to specify your own names if the folders aren't descriptive enough.


<?
// Locator Line Based On Directory Structure
// Author WhatAShocker
//---------------------------------------------------------------------------------
// Mappings for locator line, Replaces folder names on server with ones you specify
// Examples: Change as needed.
       
$LocationMappings = array(
        
"dir1"   => "Directory 1",
        
"about"  => "About The Company"
        
);
//-------------------------------------------------------------------------------/
function LocatorLine()
{
       global 
$SCRIPT_NAME$LocationMappings;
       
$file=1// 1 Doesn't show the file name, 0 Does

       
$locationArray explode("/",$SCRIPT_NAME);
       
$locationHref "";

       echo 
'<a href="/">Home</a>';
       for(
$i=1$i<count($locationArray)-$file$i++)
       {
          if ( !empty(
$LocationMappings[$locationArray[$i]]) ) {
             
$locationText $LocationMappings[$locationArray[$i]];
          }
          else {
             
$locationText ucwords($locationArray[$i]);  //Uppercase letters
          
}
          
$locationHref .= "/" $locationArray[$i];
          echo 
"&nbsp;>>&nbsp;<a href="$locationHref">$locationText</a>";
       }
       echo 
"n";
}
//-------------------------------------------------------------------------------/

LocatorLine()
?>


Usage Example




Rate This Script





Search



This Category All Categories