Showing posts from 2012

Get the CatalogNode of Product Listing Page

There are some instances when we need to know the Parent nodes of a Page based on [catalogue] Product Listing. E.g. I have a scenario when we are setting up header menus for products. Editor can select a parent Node for display child nodes as menus. But episerver classes doesnot provide any public function to return the CatalogNode of an active Product listing page. Following piece of code can help us in these scenarios.

privatestring nodeName = string.Empty;
//Is it a category listing Page bool isCatalogNodePage = BreadcrumbsFactory.IsCatalogNodePage(CurrentPage); //Is it a product listing page bool isProductPage = BreadcrumbsFactory.IsProductPage(CurrentPage);

//Get the parent catalog node/s of this page. if (isCatalogNodePage) { CatalogNode node = CurrentPage.GetParentCatalogNodeCode(); if (node != null)               nodeName = node.ID;        } elseif(isProductPage)        { CatalogNode node = CurrentPage.GetParentCatalogNodeCode(); do               { if (node != null)               { if (string.IsN…