SiteMapTitle for parent node

Apr 7, 2011 at 4:11 PM

Hi,

the SiteMapTitle Attribute works very nice for me, but i got a question.

my sitemap looks like:

=>producttype

===>productcategory

=====>product

I use the breadcrumb view with the sitemaptitle attribute to show the current type/category/product name in the breadcrumb.

My problem is that if i show the product view, i don't know how to set the sitemaptitle for the parent node (category in this case).

Is there a simple way to do this?

Regards,

Chris.

Apr 20, 2011 at 9:04 AM

One option is to say the following in your product action method:

// Override the parent node title and url
SiteMap.CurrentNode.ParentNode.Title = product.Category.CategoryName;
SiteMap.CurrentNode.ParentNode.Url = Url.GenerateUrl("Index", new { categoryID = product.Category.CategoryID });

The only problem i have found with this approach is that it breaks under heavy load (see http://mvcsitemap.codeplex.com/workitem/5839 for details on the issue).  I have had to resort putting my breadcrumb in it's own ContentPlaceHolder which can then be overridden in the product view.

Hope this helps.

May 2, 2011 at 8:10 AM

Thank you for the reply. I've found out another possible option. There is the SiteMapTitleAttribute, which i extended to take more parameters.

Not i use it this way:

        [SiteMapAdvancedTitle("NodeTitle", "ParentNodeTitle", "ParentNodeUrl")]
        public ActionResult Details(string slug) {...}

works fine i suppose, since i haven't tested it under heavy load yet.