Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Breadcrumb component issues
Bowker
So I'm using the OOTB external for breadcrumbs and find that the information I'm receiving is, on occasion, not for the current page I'm on.
The component is setup as "Do not cache".
I have setup an infinite loop on my machine to get five different pages from the server. When I use a browser to hit a different page, the breadcrumb I get back is one of six. Either the page I'm actually looking at or one of the other five pages.
It appears to be cross-thread-contamination.
Has anyone else seen this? And if so what did you do?
[HTML]
true
com.interwoven.livesite.external.impl.Breadcrumb
displayBreadcrumb
[/HTML]
Find more posts tagged with
Comments
Rick Poulin
That code is borked in some versions of TS, 7.2.1 in particular if memory serves. It correctly retrieves the sitemap, but the logic to prune the tree to only the current page is incorrect. Last I checked, it did something silly like always going down the first child under certain circumstances.
The fix is to write your own external to retrieve the sitemap Document:
Document doc = new LivesiteSiteMap().getSiteMap(context);
and then to do the document pruning yourself.
EDIT: Feeling generous today, so here ya go. Exception handling is left up to you. Code provided without any guarantees and so on. I also don't remember if getSiteMap(context) picks out the relevant segment for you, so if you're using targeting, do more testing.
[PHP]
public Document getBreadcrumb(RequestContext context) {
Document doc = new LivesiteSiteMap().getSiteMap(context);
String curPage = context.getPageName();
// find the current page in the tree
Node targetNode = doc.selectSingleNode("//node[./link/value='" + curPage + "'][./link/
@type=
'page']");
if (targetNode == null) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Node for " + curPage + " not found");
}
doc.selectSingleNode("/site-map/segment").detach();
return doc;
}
Element curElement = (Element) targetNode;
// remove children
for (Element e : (List) curElement.elements("node")) {
e.detach();
}
// walk up the tree and remove siblings
while (curElement.getParent() != null) {
List siblings = curElement.selectNodes("../node");
for (Node sib : siblings) {
if (sib != curElement) {
sib.detach();
}
}
curElement = curElement.getParent();
}
return doc;
}
[/PHP]