Question

i've recently started to use marteenba's sitemap provider, because i couldn't solve a route problem with the other sitemap i had. It's way better than my previous one. My question is: how can i create different breadcrumb trails from pages that go to a single main page? Consider the idea below:

Sitemap Structure

<mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">
       <mvcSiteMapNode title="Clients Search" controller="ClientBussiness" action="ClientSearch" description="Clients Search">
            <mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
        </mvcSiteMapNode>

        <mvcSiteMapNode title="Advanced Search" controller="ClientBussiness" action="AdvancedSearch" description="Clients Advanced Search">
            <mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
        </mvcSiteMapNode>

        <mvcSiteMapNode title="Another Search" controller="ClientBussiness" action="AnotherSearch" description="Clients Another Search">
            <mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
        </mvcSiteMapNode>
</mvcSiteMapNode>

On the example above, my breadcrumb trail always shows the node Clients Search instead of any other. I don't know if should create different routes for each kind of search (i did this on my last sitemap, but unfortunately iis6 didn't like it).

I appreciate your help.

EDIT

searching on forums i found a similar question. So, consider the structure below:

Home >> Search >> Contracts
Home >> Another Search >> Contracts
Home >> Advanced Search >> Contracts
Home >> Web Service Search >> Extra fields >> Contracts
Was it helpful?

Solution

Well it seems that all i needed to do was to add some dynamic nodes attributes on my controllers. You can read how to do it here. Using the example above, here's how it's done:

 [MvcSiteMapNodeAttribute(Title = "Search", Key = "search", ParentKey = "ContractSearch", Route = "SearchRoute")]
        [MvcSiteMapNodeAttribute(Title = "AdvancedSearch", Key = "ContractAdvSearch", ParentKey = "AdvSearch", Route = "AdvSearchRoute")]
        [MvcSiteMapNodeAttribute(Title = "AnotherSearch", Key = "ContractAnotherSearch", ParentKey = "AnotherSearch", Route = "AnotherSearchRoute")]
        public ActionResult ContractIndex()
{
   //Things to do...         
}

On the example above, each kind of search will be properly defined on the breadcrumb trail. Keep in mind that you have to define different routes for each kind of "search" you want to use. So, if you want to have 3 nodes pointing to the same url, each node must have it's own route and it's key, defined on MvcSiteMapNodeAttribute.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top