Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi, I know this post is a little old, but I am having some trouble making the code work, and I would appreciate any advice! Right now, I am using the following function to create the list of breadcrumbs:
<!--- generate breadcrumbs --->
<cffunction name="getBreadcrumbs" returntype="string" access="public" output="false">
<cfargument name="pageID" required="yes" type="numeric">
<cfset var vBreadcrumbs = '' />
<cfquery name="qGetPageInfo" datasource="#application.db#" maxrows="1">
SELECT
*
FROM
admin_navigation
WHERE
id = <cfqueryparam value="#arguments.pageID#" cfsqltype="cf_sql_integer">
</cfquery>
<!--- 0 is a top level item --->
<cfif qGetPageInfo.parentID NEQ 0>
<cfset vBreadcrumbs = getBreadcrumbs(qGetPageInfo.parentID) />
</cfif>
<cfset vBreadcrumbs = listAppend(vBreadcrumbs, qGetPageInfo.pageName) />
<cfreturn vBreadcrumbs />
</cffunction>
This is being used to display the breadcrumb function:
<cfset getBreadcrumbsQuery = application.adminObject.getBreadcrumbs(pageID) />
#listChangeDelims(getBreadcrumbsQuery, " » ")#
However, what I get is a list with the correct number of levels, but the page name that is displayed is always the top-level breadcrumb that should be called. For example, I should see Courses >> Core Course Management for the page I am testing on, and instead I just get Courses >> Courses.
I would appreciate any pointers in the right direction! Thanks.
KC
Copy link to clipboard
Copied
You shouldn't really hijack someone else's thread (even a long dead one) with your own question. Etiquette is generally "one question per thread".
First things first, you need to VAR all your variables in your function. This is especially critical when recursing, because otherwise each new call will overwrite the variables from the previous call.
Get that sorted out first.
Second - and this is unrelated to your immediate issue, but it's just poor form - never use SELECT * unless you actually want all columns in the result set. Even then, it's still better to list all the columns. For your purposes here, you only need a couple of columns, so only fetch those columns.
Third - the adjacency list model (ID / PARENT_ID) for representing a hierarchy is not very performant, and does not scale. I recommend using the nested set model instead.
Ooh... fourth... what DB system are you using? Depending on your answer you can probably dispense with the recursion and get the DB to get the results with a single query.
--
Adam
Copy link to clipboard
Copied
Sorry about that, I have reposted here: http://forums.adobe.com/thread/485755
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied