OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.37k stars 1.12k forks source link

Url.ItemDisplayUrl with custom AutoRoute #2402

Open orchardbot opened 12 years ago

orchardbot commented 12 years ago

@IvanFeric created: https://orchard.codeplex.com/workitem/18575

Could Url.ItemDisplayUrl be modified so that it returns custom AutoRoute URL that users entered if it exists and not the defaultly generated AutoRoute URL as it does now?

orchardbot commented 12 years ago

@bleroy commented:

I think the bug is that when more than one alias exists for a given content, the one that is persisted with the item does not necessarily win when generating URL from standard MVC API.

orchardbot commented 12 years ago

@IvanFeric commented:

Exactly that!

If content item was created with AutoRoute URL, and afterwards decides to change that URL to another, custom URL, the URL that is displayed throughout the front end is the first, automatically generated URL instead of the custom one.

orchardbot commented 12 years ago

ermakovich commented:

I will appreciate, if you include this fix in 1.4.1. For me impact of this issue is really high...

orchardbot commented 12 years ago

@bleroy commented:

Can you explain why impact is high?

orchardbot commented 12 years ago

ermakovich commented:

  1. I'm actively using Taxonomies module. When you navigate to the taxonomy term URL (like yourwebsite//), it should be exactly the same, as it specified in the Permalink field. Otherwise, it will always return empty list, even if the alias is correct.
  2. I'm using widget layers with url-based rules. If old alias win, I get problems with my url-based layers.

From my perspective, it would be nice, if old aliases would be used for backward compatibility only, and when client navigates to it, Orchard would automatically redirect him to the most relevant alias.

orchardbot commented 12 years ago

cwoodhouse commented:

yeah, basically when using autoroute, if you allow the default route to be overridden in the editor and someone overrides then the frontend url generated by Url.ItemDisplayUrl doesn't always use that alias, it uses the old one rather then the latest.

orchardbot commented 12 years ago

@sebastienros commented:

Postponed to later version.

After some investigation, an AliasRoute is created for each of the available aliases. When GetItemDisplayUrl is called, the RouteValues are something like Contents/Display/Id, which then can be resolved by several alias. It results that several alias routes do match this one, thus, several possible paths. There is currently no implemented way to make a specific alias have a higher priority than the others.