CFLib.org – Common Function Library Project

breadCrumb()

Last updated July 25, 2006

author

Jon Lesser

Version: 1 | Requires: CF5 | 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:

/**
 * 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;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson