Breadcrumb implementation problem
Closed this issue · 6 comments
Is it possible to implement this?
Example:
Home > Cars > 1 > Edit
I mean "1" labeled item and clicking it going to the details view.
I'm only able to replicate this:
Home > Cars > Edit
If 1 is an existing node in the navigation tree you can adjust the text and link from inside a controller action as shown in the document here: https://www.cloudscribe.com/docs/adjusting-menu-items-per-request
If it is not a node in the tree you can potentially add it as a "TailCrumb" https://www.cloudscribe.com/docs/adding-extra-breadcrumbs
Beyond that I don't know, I implement this project to meet my own needs and hope others find it useful but I cannot promise it meets every need for every project.
It's not an existing node, I have in navigation.xml (pseudocode):
<node controller="Home" action="Index"> <node controller="Cars" action="Index"> <node controller="Cars" action="Edit" preserve="id" />
That's why I only get:
Home > Cars > Edit
And not:
Home > Cars > 1 Edit
I don't know how to resolve this if it's possible.
I have no idea about what you are actually doing. pseudo code (which looks wrong) isn't going to cut it if you want help. You are not providing enough information.
Sorry, I'm going to explain it better.
I want a breadcrumb that displays:
Home (link to: /) > Cars (link to: /cars) > 1 (link to: /cars/1/details) > Edit
Now I have something like this:
<?xml version="1.0" encoding="utf-16"?>
<NavNode controller="Home" action="Index" text="Home" isClickable="true">
<Children>
<NavNode controller="Cars" action="Index" text="Cars" isClickable="true">
<Children>
<NavNode controller="Cars" action="Edit" text="Edit" preservedRouteParameters="id" />
</Children>
</NavNode>
</Children>
</NavNode>
But this only gives:
Home > Cars > Edit
Not:
Home > Cars > 1 > Edit
I don't have any way for you to inject an extra node in between a parent node and a child node.
Myself I would not put the edit link in the menu I would surface it in the detail view only if the user has edit permission.
Nevertheless, if I wanted to do that I am sure I could do that and I will tell you how I would do it.
-
I would remove the edit node from the xml
-
In the get actionmethod for details in the cars controller I would add 2 tailcrumbs, one for the detail page and then one for the edit if the user can edit. You probably also need to add the tailcrumbs in the get actionmethod for edit
-
The problem will be that breadcrumbs are not shown on the detail url because the detail url is not in the xml and is not a node in the tree therefore currentnode in the viewmodel will be null. To solve that I would implement and inject a custom IFindCurrentNode that can detect if the current url is the cars detail url or the edit url, and if so then return the index node as the current node so it will not be null and it will show breadcrumbs and the tailcrumbs will be rendered as if they are children of the index node.
-
You will need to use a custom view for the breadcrumbs because the default one would not render links for the tailcrumbs
All of the above is discussed in the article Adding Extra Breadcrumbs the only difference is you want 2 extra breadcrumbs not just one and you want them to be links.
Ok, thanks, I will try that.