Home > Web Design > Perl > PerlCrumbs 1.5 Search this site:   
  Janis Kenderdine's Home on the Web  

Fifer’s Web site — on the Web since 1995!

 
My Web Sites | How’d You Do That? | Screen Design & Layout | My Perl Scripts

PerlCrumbs 1.5

Disclaimer

Feel free to use, copy, distribute, and change - but you use it all at your own risk. I take no responsibility for any issues that might arise through use of any of my code.

Hopefully you’ll find something useful in here. If you have any questions, feel free to e-mail me and maybe I’ll know the answer.

Skip to the Download & Installation Instructions


Revision History

PerlCrumbs 1.5 Posted: 29 December 2006

I had a request to make it so that index pages that opt out of using a final separator can also have the final directory name without a link.

i.e. Instead of:

you now have the option of

Home > Documents

(Roll over each link to show which have links and which don’t.)

PerlCrumbs 1.4 Posted: 13 September 2006

Fixed a minor run-time bug that showed the final separator on the Home page.

PerlCrumbs 1.3 Posted: 11 April 2006

I had a request to make an option for those who don’t want to put in a (duplicate) index-title.

i.e. Instead of:

Home > Documents > Documents Page

or

you now have the option of

How much does this script cost? Nothing! Zip, nada, nichts. Totally free, my gift from me to you. Why? Because I’m nice like that. (See the disclaimer at the top of the page). If you’d like to do something for me in return, e-mail me and let me know what page/site you’re using my script on, so I can show it to my friends. “Hey! People use my script! See?”

Enjoy!

PerlCrumbs 1.2 Posted: 12 February 2006

I’ve added a target="_blank" (or target= whatever you want) option for those people using frames. I also added the option to use a default page other than “index.html” or whatever /directory/ goes to by default. (Again, usually for frames). This shouldn’t apply to most people. If you have Perlcrumbs 1.0 or 1.1 installed and working, don’t bother reinstalling 1.2.

PerlCrumbs 1.1 Posted: 29 August 2005

Nothing in the code is really changed - I just can’t spell “separate” so I fixed that. :-P If you have Perlcrumbs 1.0 installed and working, don’t bother reinstalling 1.1.

PerlCrumbs 1.0 Posted: 17 January 2005

Free perl cgi breadcrumbs download!

I couldn’t believe how difficult it was to find a simple cgi perl script to make breadcrumbs (like the thing in the upper left corner showing directories). So... I wrote one. You should have some minor perl experience, or at least be able to figure out what needs to be customized...

Example:

Download & Installation Instructions

Installation
  • Server-side includes need to be enabled on your server
  • Try dumping this ssi into your web page and make sure it returns a value: <!--#echo var="REQUEST_URI" -->
  • Save the script to your cgi-enabled directory: perlcrumbs1.5.tar
  • tar xvfp perlcrumbs1.5.tar to decompress
  • Make sure the opening #! is correct for your system
  • Make sure the permissions are set to read and execute, or do a chmod 755 perlcrumbs1.5.cgi
Customizing the script

Start customizing things in the code:

#############CUSTOMIZE HERE ###############

## SSI supported filename extension
## (usually .shtml, but sometimes configured in the server 
## config file for use with .html or .htm)
$extension = '.shtml';

What is the extension of your pages? .shtml? .html? .htm? Make sure server-side-includes are supported by whatever extension you use. The default configuration on most Apache systems is to allow .shtml pages to use server-side includes. Some may be configured to let other types of files (.html, .htm) process them, as well. If you can’t get the <!--#echo var="REQUEST_URI" --> on your test page to work, try it on a page with a .shtml extension.

"But all my pages end in .html! You mean I have to change them all to .shtml?"

No, but if you want to get around changing everything, you’ll have to contact your system administrator and ask him/her to change the config file to allow files ending in your extension to parse server-side-includes.


## Separator you want to use for display between directories
## (Use of html-safe encoding recommended)
$dirseparator = ' &gt; ';

This is where you determine what you want to use to separate the directories with. Do you want a > symbol? The html code for this is &gt; - or if you wanted to use a slash, put in a slash, or a vertical bar | like in the example here. HTML-safe encoding is recommended for any wierd characters.

Example:

$dirseparator = ' | ';

## You must have a "directoryname, displayname"
## pair for each directory, or it won't show up.
%sitemap = (	
	misc, "Miscellaneous",
	news, "News",
	perl, "Perl",
	photos, "Photos",
	webdesign, "Web Design",
	cin, "Cinnamon",
	sunny, "Sunny",
);

This is where you assign names to the directories. The directory names in the directory hierarchy on your server is the left element in the pair, and your “english” display-name is the right element. It doesn’t matter what order these are in, or how they pertain to the directory structure. Don’t use mydir/special, “Special Directory” to skip over mydir. Just don’t make mydir a pair, (but make a special, “Special Directory” pair) and it will skip over naming it.


## Uncomment this if your home directory is
## http://www.yourdomain.com/ (the site root)
## and give the home directory a display name
#$homedir = "Home";

This one’s pretty self-explanatory. Is your site root the same as the domain-name root? (http://www.fifegeek.com/) Or is it a subdirectory on a server owned by your friend, like mine used to be? (http://www.fifedrum.org/fifer/)

If it’s the same as the domain-name, then delete the # at the beginning of the $homedir = "Home"; line so it reads:

Example:

$homedir = "Home";

## Uncomment this and apply any classes, id's, or targets
## that need to go within the <a href> tag
#$hrefargs = 'class="menu" id="whatever" target="_blank"';

If you have a css style applied to hyper-links (within the <a href> tag), assign its value here and delete the # at the beginning of the line. If you don’t have anything, just leave it commented out.

Example:

$hrefargs = 'class="highlight"';

## Uncomment this and apply default pages for directories
## (Most people are best leaving this commented, which will
## use "index" as their default directory page)
#$defaultindex = 'home';

If you have a default page (other than index) for each directory (as is sometimes the case when using frames) you’ll need to define the default page here. (<a href="/directory/home.html">) Otherwise, href’s will go to <a href="/directory/">

Example:

$defaultindex = 'home';

## Comment this out (put a # in front of $finalseparator = $dirseparator
## if you don't want to put in a title for index.(s)html 
## pages
## i.e.
## Home > Documents
## instead of:
## Home > Documents >
$finalseparator = $dirseparator;

You don’t need to do anything here, unless you don’t want a final separator. Some people would prefer to just leave the directory name for index pages, and only add names for sub-pages of that directory.

If you want to leave the final separator off of index pages, put a # in front of the line so it reads:

#$finalseparator = $dirseparator;

## Uncomment this (remove the # in front of #$finallink = 'none';
## if you don't want to put in a link for index pages
## pages
## i.e.
## Home > Documents
## linked > not linked
## 
## RECOMMEND: Commenting out the $finalseparator = $dirseparator if 
## you're going to uncomment this option, or it will place a
## final separator AFTER your unlinked directory name.

You don’t need to do anything here, unless you don’t want the final directory name to have a link. Some people would prefer to just leave the directory name for index pages, and only add names for sub-pages of that directory.

If you want to leave the final directory link off of index pages, remove the # in front of the line so it reads:

$finallink = 'none';

It is recommended that you place a # in front of the $finalseparator = $dirseparator; line, as well (in the step prior to this).


################### STOP ##################
##Nothing below needs to be touched
################### STOP ##################

Good! You should be done customizing the script, and should be ready to stick it on a page!

Including the script on pages

On each page, put the following line where you want the breadcrumbs to show up:

<!--#include virtual="/fifer/cgi-bin/perlcrumbs1.5.cgi" --> (pointing to the actual location of the script, of course)

Make sure there’s a space between the quotes and the --> or it won’t work on some (all?) machines.

If you have a name for the page you’re on, put that after the include directive so it reads like:

<!--#include virtual="/fifer/cgi-bin/perlcrumbs1.5.cgi" --> This Page’s Name

On Apache, you can set variables and do the following. I’m not sure about other servers.

If you have your breadcrumbs in an include file that’s repeated on all pages (like a header or footer), you can pass the individual page names to it by putting an ssi directive on each individual page:

<!--#set var="pagename" value="This is the Awesome Page" -->

Then in the include, put in:

<!--#include virtual="/fifer/cgi-bin/perlcrumbs1.5.cgi" --><!--#if expr="${pagename}"--><!--#echo var="pagename" --><!--#endif -->

It should show something like:

Home > Web Design > Perl > This is the Awesome Page

If you have any problems, e-mail me.