Is there a way to substitute DocumentNamePath in Xperience 13?

Charles Levesque asked on June 21, 2023 16:16

Hello all!

We are currently in the process of upgrading a MVC5 website from Kentico 12 SP to Xperience 13, but we are facing a bit of a problem. Here it is:

Our website uses custom routing to provide the basic routing to the pages as well as other types of routes needed for other systems. A typical multilanguage route looks like this:

  • In English: /en/a-nice-article
  • In French: /fr/un-bel-article

To make it happen in Kentico 12, we have a URL pattern like this on every page type: /{%DocumentCulture.Substring(0,2)#%}{%DocumentNamePath%}. Then in the backend we parse the URL to get the language and query the DocumentNamePath with the rest of the URL. We are trying to remake the multilanguage routes described in Xperience 13, but we can't find a way to add a correct substitute for DocumentNamePath in the URL pattern.

Does anyone have a suggestion for me? After trying a few things, I'm open to new ideas. The closest I got was with NodeAliasPath, but it doesn't provide a way to get multilingual URL.

Thanks a lot for your time.

Charles =)

Correct Answer

Arjan van Hugten answered on June 22, 2023 15:40

I would suggest to use the Kentico content tree based routing. Here you can use the culture alias to create the same effect that you have with your macro in the URL pattern and you can use language specific slugs.

You do need to do some development to preserve the previous URLs

0 votesVote for this answer Unmark Correct answer

Recent Answers


Charles Levesque answered on July 12, 2023 20:52

Thank you for your answer Arjan. I went in that direction in the end.

For posterity, here's what I did briefly for people that have the same problem:

  1. I switched to content tree-based routing in the settings.
  2. Then, I reviewed the custom routing code that was querying Kentico for the correct content based on the node alias path or document name path and determined which controllers were using this.
  3. For those controllers, I used the attribute RegisterPageRouteAttribute as described here.
  4. If you were passing the node alias path as a parameter of a method, you can replace that by injecting IPageDataContextRetriever and call Retrieve<TreeNode>().Page.NodeAliasPath.
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.