cloudscribe/cloudscribe.Web.Navigation

Dinamic parameter

Closed this issue · 2 comments

Hello,
Not exactly an error, but I have not found another way to communicate :)

I am trying to create the following menu:

<NavNode key = "AlertaDetalle" parentKey = "Alerts" controller = "notification" action = "Details / 1 / {id}" text = "Detail" componentVisibility = "breadcrumbs">

<NavNode key = "CircularDetalle" parentKey = "Circulars" controller = "notification" action = "Details / 2 / {id}" text = "Detail" componentVisibility = "breadcrumbs">

But the breadcrumb not shown, I understand that is because in NavigationViewModel.CurrentNode is also looking
currentNode = RootNode.FindByUrl (UrlHelper, context.Request.Path, nodeSearchUrlPrefix);

and context.Request.Path comes for example Details/ 2/45 and this is not in the xml.

It is possible to have parts of the dynamic url?

Thank you

Edit:

I believe this operation could be done with the option PreservedRouteParameters and send the "type" parameter for GET(Details/id?type=1), but I wonder if possible through parts of the url.

The navigation.xml and the tree builder don't have a good way to know about the route parameters for a dynamic url. But for breadcrumbs there is a way to update it from the controller action for the current request like this:

    var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext);
    currentCrumbAdjuster.KeyToAdjust = "AlertaDetalle";
    currentCrumbAdjuster.AdjustedText = "Set this if you need to update the label";
    currentCrumbAdjuster.AdjustedUrl = "resolve your url with parameters here";
    currentCrumbAdjuster.AddToContext();

the adjuster allows you to update the node identified by the Key for the duration of the current request, so whatever the current detail item is you can use that to update the text and/or the url of the node from within the controller action code

Thank you!!

Just I try now and it works!