CFLib.org – Common Function Library Project

breadCrumb()

Last updated July 25, 2006
Download UDF

author

Jon Lesser                                        Jon Lesser

Version: 1 | Requires: ColdFusion 5 | Library: StrLib

Description:
BreadCrumbs() can be called from any page and will return a string of links.

Return Values:
Returns a string.

Example:

<span class="breadCrumbLinks"><cfoutput>#BreadCrumb()#</cfoutput></span>

Parameters:

No arguments.

Full UDF Source:

<cfscript>
/**
* Creates a bread crumb trail based on your sites sirectory structure.
*
* @return Returns a string.
* @author Jon Lesser (jdl1101@rit.edu)
* @version 1, July 25, 2006
*/

function breadCrumb() {
    var baseLink = "/";
    var delimiter = " > ";
    var crumbs = "<a href='" & baseLink & "'>Home</a>" & delimiter;
    var breadCrumbArray = listToArray(replace(cgi.script_name, "_", " ", "all") , "/");
    var i = 1;
    
    for(i=1; i lt arrayLen(breadCrumbArray); i=i+1) {
        baseLink = baseLink & replace(breadCrumbArray[i], " ", "_", "all") & "/";
        
        if(i lt ArrayLen(breadCrumbArray)-1) crumbs = crumbs & "<a href='" & baseLink & "'>" & capFirstTitle(breadCrumbArray[i]) & "</a>" & delimiter;
        else crumbs = crumbs & capFirstTitle(breadCrumbArray[i]);        
    }
    return crumbs;
}
</cfscript>

Search CFLib.org


Latest Additions

Raymond Compton Raymond Compton added
structBlend
19 day(s) ago

Duncan Duncan added
IsZIPUK
19 day(s) ago

Todd Sharp Todd Sharp added
getTagContentAll
25 day(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Created by Raymond Camden / Design by Justin Johnson