cloudscribe/cloudscribe.Web.Navigation

Breadcrumb for same action from different Views

Closed this issue · 2 comments

Potential duplicate of [https://github.com//issues/43]

I have same controller action(Opportunity/Add) called from multiple views. I need to the bread crumb to exactly point out the view it came from. This is how my navigation.xml looks

<NavNode key="Home" controller="Home" action="Index" area="" preservedRouteParameters="culture" text="Home" iconCssClass="glyphicon glyphicon-home" isRootNode="true">
  <Children>
   <NavNode key="Companies" controller="Companies" action="Index" area="Dashboards" text="Companies">
      <Children>
        <NavNode key="CompaniesOppAdd" controller="Opportunity" action="Add" area="" preservedRouteParameters="orgCode, parent" text="Add Opportunity" />
      </Children>
    </NavNode>
    <NavNode key="Contacts" controller="Contacts" action="Index" area="Dashboards" text="Contacts">
      <Children>
        <NavNode key="ContactsOppAdd" controller="Opportunity" action="Add" area="" preservedRouteParameters="orgCode, parent" text="Add Opportunity" />
      </Children>
    </NavNode>


image

But, I always get the same breadcrumb as above irrespective of whether I load from the company page or contact page.

Is it possible to see Home / Contatcs / Add Opportunity when I load from contact page?

Thanks for the help.

Is anybody able to comment on this?

Hi @TimSirmovics @sannip sorry for slow response - somehow we all had notifications off for this repository.
I believe it will by default show the first match for the controller/action, and so you get Home / Companies / Add Opportunity every time.
So one simple answer is to have an action for each of the different "Add Opportunity" nodes - they could all call the same action underneath. So you have make actions AddCompanyOpportunity and AddContactOpportunity, in turn calling your original Add action. If you use these more specific actions in navigation.xml I think you'll get the desired breadcrumbs.
Or, and I've not tried it for your scenario, I think you can find a more sophisticated solution using the NavigationNodeAdjuster documented here https://www.cloudscribe.com/adjusting-menu-items-per-request