ASP/XML breadcrumb issue

Results 1 to 4 of 4

Thread: ASP/XML breadcrumb issue

  1. #1
    Randell Witmann Guest

    Default ASP/XML breadcrumb issue

    Hi<BR><BR>I have menaged to get a breadcrumb using XML/ASP to work 75% of the time. My issue is that it falls over for first time visitors / new sessions. My ASP grabs a queryString "category" and "link" and uses this with the xml parser to build dynamic xml for the breadcrumb. <BR><BR>Only thing is short of placing a variable in every asp page to set the "category" and "link" querystring name/value pairs and doing a check if the page is an new session, it falls over.<BR><BR>An ideas ? The code is 115 lines long, if you want to see it please say and I will post it...

  2. #2
    Join Date
    Dec 1969

    Default RE: ASP/XML breadcrumb issue

    Can U post it ??

  3. #3
    Randell Witmann Guest

    Default Complete code

    Here is the complete file. The quwerstring basically should be something along the lines of "?Category=USA OPT" and then there is the "link" name/value in the XML. All links within the site have just ?Category=.... in the "inline" method...<BR><BR>TIA for any insight<BR><BR>&#060;%<BR> Dim strCrumb<BR> Dim strXMLCrumb<BR> Dim xmlDoc<BR> Dim objCurrNode<BR> Dim objAttrib<BR> Dim objChild<BR> Dim strLink<BR> Dim strTitle<BR> Dim strReqLink<BR> Dim mDummy<BR> Dim patharrows<BR><BR> patharrows = "&nbsp;&#060;b&#062;&#124&#060;/b&#062;&nbsp;"<BR>function buildXML_emptyCrumb(strCrumb,strCurrentCrumbTitle, strReqLink,strXMLCrumb)<BR><BR> strCrumb = strCrumb & strCurrentCrumbTitle<BR> strXMLCrumb = "&#060;breadcrumb&#062; " & vbcrlf & "&#060;page " & "title=""" & strCurrentCrumbTitle & """ " & _<BR> "link=""" & strReqLink & """&#062;&#060;/page&#062;" & vbcrlf & "&#060;/breadcrumb&#062;"<BR> <BR> buildXML_emptyCrumb = strXMLCrumb<BR><BR>End function<BR> <BR>function writeBreadCrumb(strCurrentCrumbTitle)<BR> <BR> set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")<BR> strXMLCrumb = Session("breadcrumbXML")<BR> <BR> &#039;----- Get currently requested page with variables<BR> strReqLink = Request.ServerVariables("URL") & "?" & Request.ServerVariables("Query_String")<BR> <BR> If strXMLCrumb = "" Then<BR> Session("breadcrumbXML") = buildXML_emptyCrumb(strCrumb,strCurrentCrumbTitle, strReqLink,strXMLCrumb)<BR> Else<BR> mDummy = xmlDoc.loadXML(strXMLCrumb)<BR> do<BR> if strCrumb = "" Then<BR> strCrumb = "&#060;a href=""/default.asp"" class=""bread""&#062;HOME&#060;/a&#062;" & ""<BR> Set objCurrNode = xmlDoc.FirstChild<BR> End if <BR> set objCurrNode = objCurrNode.firstChild <BR> for each objAttrib in objCurrNode.attributes<BR> if objAttrib.baseName = "title" Then<BR> strTitle = UCase(objAttrib.text)<BR> end if <BR> if objAttrib.baseName = "link" then<BR> strLink = objAttrib.text<BR> end if<BR> next<BR> if strCurrentCrumbTitle = strTitle Then<BR> if objCurrNode.hasChildNodes() = true then<BR> for each objChild in objCurrNode.childNodes<BR> objCurrNode.removeChild objChild<BR> next<BR> end if <BR> for each objAttrib in objCurrNode.attributes<BR> if objAttrib.baseName = "link" then<BR> objAttrib.text = strReqLink<BR> end if<BR> next <BR> strCrumb = strCrumb & strTitle<BR> exit do<BR> <BR> else<BR> strCrumb = strCrumb & "&#060;a href=""" & strLink & """ class=""bread""&#062;" & strTitle & "&#060;/a&#062;" & pathArrows<BR> if objCurrNode.hasChildNodes() = False then<BR> set objChild = xmlDoc.createNode("element","page","")<BR> set objAttrib = xmlDoc.createAttribute("title")<BR> objAttrib.text = strCurrentCrumbTitle<BR> <BR> Set objAttrib = objChild.attributes.setNamedItem(objAttrib)<BR> set objAttrib = xmlDoc.createAttribute("link")<BR> objAttrib.text = strReqLink<BR> <BR> set objAttrib = objChild.attributes.setNamedItem(objAttrib)<BR> set objChild = objCurrNode.appendChild(objChild)<BR> strCrumb = strCrumb & strCurrentCrumbTitle<BR> exit do<BR> else<BR> &#039;----- Do nothing<BR> end if<BR> End If<BR> loop<BR> session("breadcrumbXML") = xmldoc.xml<BR> <BR> end if<BR> <BR> response.write ("&#060; b&#062;" & strCrumb & "&#060; b/&#062;")<BR> set xmlDoc = Nothing<BR> set objCurrNode = Nothing<BR> set objAttrib = Nothing<BR> set objChild = Nothing<BR> End function<BR> <BR> Function breadCrumbOut()<BR> <BR> dim strCategory<BR> dim strCrumbTitle<BR> <BR> strCategory = Trim(Request.QueryString("Category"))<BR> <BR> strCrumbTitle = strCategory<BR> <BR> writeBreadCrumb(strCrumbTitle) <BR> End Function<BR>%&#062;

  4. #4
    Randell Witmann Guest

    Default Extra note

    I can currently get the code to fill in the initial "crumb" with the code below:<BR><BR>strCrumb = "&#060;a href=""/default.asp?Category=GLOBAL%20HOME"" class=""bread""&#062;HOME&#060;/a&#062;" & ""<BR><BR>My problem with this is that it wont build the first crumb corresponding to the correct page, it will always show HOME and link to that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts