Forums
This topic is locked
bread crumb navigation
Posted 08 May 2003 20:29:50
1
has voted
08 May 2003 20:29:50 Anonymous User posted:
Does anyone know of a good ASP VBScript solution for bread crumb navigation that would work on an NT4 server? I'd like to have it at the top where it says:Home >> Division1 >> Subdivision2
with each linking back to the higher level.
Ideas anyone?
Why be difficult when you can be impossible?
Replies
Replied 08 May 2003 22:21:20
08 May 2003 22:21:20 Brent Colflesh replied:
There are a ton of pre-made solutions - check Google - ex:
www.needscripts.com/Resource/8363.html
Regards,
Brent
www.needscripts.com/Resource/8363.html
Regards,
Brent
Replied 14 May 2003 18:11:57
14 May 2003 18:11:57 Matthew Maguire replied:
WyrdMagick,
I've been developing a database-driven website for some time, and I needed a breadcrumb trail too, so this is how I did it.
In my database I had two tables, one called content where my 'pages' were stored, and one called 'folders' where virtual folders were stored.
Each folder had a unique ID, but also a column called 'folder_link_id'. If the number folder-link was "0" then the folder was a root folder. If not, the the folder was located 'virtually' in the folder with the same number as its folder_link_ID. Through this system an infinite number of folders could be created, and located in any other folder.
In the content table, one of the columns was 'folder_link_id', containing the ID number of an existing folder.
Thus, a page called "Information" could be located in a folder called "Services" which could be located in a folder called "products".
The creation of the breadcrumb trail is fairly straight forward. First I will include a plain-english version, and the section from my website.
### Start of code: ###
- Get current pages ID number?
- Which folder is the current page linked to?
- get the folders' name + ID number
- get the folders' folder_link_ID
- Is the folder a root folder?
- if so, do nothing
- if not, then process that folder
- Display information
### End code ###
Below is the real code.
Note: the word "departments" means "folders"!
Note: <asp-start/end-tags> are where normal tags should be. Can't use them in the forum!
' ######## NAVIGATION BAR ########
' GET HOME DEPARTMENT INFO
Dim home_department_title, home_department_id
conn.source = "SELECT department_id, department_title FROM departments WHERE department_class = 'home'"
conn.Open ()
home_department_id = conn.Fields.item("department_id".value
home_department_title = conn.Fields.item("department_title".value
conn.Close()
' PRODUCE PAGE NAVIGATION VARIABLE
' Go though each folder in tree and get info
Dim navigation_cycle, department_cycle, cycle_status
department_cycle = content_department_link
navigation_cycle = ""
while NOT cycle_status = "done"
conn.source = "SELECT department_id, department_title, department_link_id FROM departments WHERE department_id = " & department_cycle & ""
conn.Open()
if conn.Fields.item("department_link_id".value = "0" then
cycle_status = "done"
navigation_cycle = navigation_cycle & conn.Fields.item("department_title".value & "," & conn.Fields.item("department_id".value
else
navigation_cycle = navigation_cycle & conn.Fields.item("department_title".value & "," & conn.Fields.item("department_id".value & ","
department_cycle = conn.Fields.item("department_link_id".value
end if
conn.Close()
wend
' PRODUCE PAGE NAVIGATION ARRAY
' Convert the folder info into an array
Dim loop_details, loop_number
oop_details = split(navigation_cycle,","
' LOOP THROUGH FOLDER TREE WRITING DETAILS TO HTML
for i=ubound(loop_details) to lbound(loop_details)
response.write("The Folder ID is: " & loop_details(i))
response.write("The name of the folder is: " & loop_details(i - 1))
next
response.write(content_title_bar_name)
If you have any problems, give me a shout.
Matthew
I've been developing a database-driven website for some time, and I needed a breadcrumb trail too, so this is how I did it.
In my database I had two tables, one called content where my 'pages' were stored, and one called 'folders' where virtual folders were stored.
Each folder had a unique ID, but also a column called 'folder_link_id'. If the number folder-link was "0" then the folder was a root folder. If not, the the folder was located 'virtually' in the folder with the same number as its folder_link_ID. Through this system an infinite number of folders could be created, and located in any other folder.
In the content table, one of the columns was 'folder_link_id', containing the ID number of an existing folder.
Thus, a page called "Information" could be located in a folder called "Services" which could be located in a folder called "products".
The creation of the breadcrumb trail is fairly straight forward. First I will include a plain-english version, and the section from my website.
### Start of code: ###
- Get current pages ID number?
- Which folder is the current page linked to?
- get the folders' name + ID number
- get the folders' folder_link_ID
- Is the folder a root folder?
- if so, do nothing
- if not, then process that folder
- Display information
### End code ###
Below is the real code.
Note: the word "departments" means "folders"!
Note: <asp-start/end-tags> are where normal tags should be. Can't use them in the forum!
' ######## NAVIGATION BAR ########
' GET HOME DEPARTMENT INFO
Dim home_department_title, home_department_id
conn.source = "SELECT department_id, department_title FROM departments WHERE department_class = 'home'"
conn.Open ()
home_department_id = conn.Fields.item("department_id".value
home_department_title = conn.Fields.item("department_title".value
conn.Close()
' PRODUCE PAGE NAVIGATION VARIABLE
' Go though each folder in tree and get info
Dim navigation_cycle, department_cycle, cycle_status
department_cycle = content_department_link
navigation_cycle = ""
while NOT cycle_status = "done"
conn.source = "SELECT department_id, department_title, department_link_id FROM departments WHERE department_id = " & department_cycle & ""
conn.Open()
if conn.Fields.item("department_link_id".value = "0" then
cycle_status = "done"
navigation_cycle = navigation_cycle & conn.Fields.item("department_title".value & "," & conn.Fields.item("department_id".value
else
navigation_cycle = navigation_cycle & conn.Fields.item("department_title".value & "," & conn.Fields.item("department_id".value & ","
department_cycle = conn.Fields.item("department_link_id".value
end if
conn.Close()
wend
' PRODUCE PAGE NAVIGATION ARRAY
' Convert the folder info into an array
Dim loop_details, loop_number
oop_details = split(navigation_cycle,","
' LOOP THROUGH FOLDER TREE WRITING DETAILS TO HTML
for i=ubound(loop_details) to lbound(loop_details)
response.write("The Folder ID is: " & loop_details(i))
response.write("The name of the folder is: " & loop_details(i - 1))
next
response.write(content_title_bar_name)
If you have any problems, give me a shout.
Matthew