Ninja-Script — When all else fails
When all else fails, what do you do? You call a ninja, and when he shows up he gives you a piece of code, or knowledge. Now this knowledge came in the form of a scriptlet which I know we frown upon, but here it is, because it runs back and finds the parent category, and if it is there then we use the logic to place a change in the sidenav of NordicTrack.
<%@ include file="CatalogUtilities.jspf" %>
<%
try {
Integer storeIdInt = Integer.valueOf((String)pageContext.getAttribute("storeId"));
Long catalogId = Long.valueOf((String)pageContext.getAttribute("catalogId"));
java.util.LinkedList list = null;
String categoryId = (String)pageContext.getAttribute("categoryId");
if(categoryId != null && !categoryId.equals("")){
list = (java.util.LinkedList)getCatGrpHierarchyByCatalogIdAndCatGrpId(request, response, storeIdInt, catalogId, categoryId);
} else {
Long catEntryId = Long.valueOf((String)pageContext.getAttribute("productId"));
list = (java.util.LinkedList)getCatGrpHierarchyByCatalogIdAndCatEntryId(request, response, storeIdInt, catalogId, catEntryId);
}
pageContext.setAttribute("rootCategory", list.getFirst());
} catch (Exception e) {
e.printStackTrace();
}
%>
What this all did for us was allow us to see the actual root parent of the catalog. So by finding that out we can then be as deep into the catalog as we want and still be able to write code that modifies something on the page based on if you are even in that category. What we ended up doing was checking the root parent to find out if the CachedSideBar.jsp needed to be modified when displayed to customers. It's all checked into CVS, so pull it down and take a look if you'd like.
Print This Post
Tags
Meta
Tonic Tweets
Archives
- February 2012
- January 2012
- September 2011
- August 2011
- June 2011
- May 2011
- April 2011
- March 2011
- January 2011
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008