Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anderson Moscarelli 3 posts 73 karma points
    Aug 23, 2018 @ 13:29
    Anderson Moscarelli
    0

    Localization Route and Node id

    Hi. I have a question regardin how umbraco handle request. i have a localized site where the countries route are like mysite.com/fr/en/ (france) , mysite.com/de/de/ (germany, german) , mysite.com/de/en/ (germany, english) and so on. My question is, the "/de/de" or "/fr/en" is the route for the country, but this is not a fisical route how unbraco deal with this request and find the corret node? There is some method that i can apply the url request and get the node id directly ?

    Thanks.

  • Marc Goodson 2138 posts 14321 karma points MVP 8x c-trib
    Aug 27, 2018 @ 10:06
    Marc Goodson
    0

    Hi Anderson

    Umbraco has a 'request' pipeline, containing a series of 'Content Finders' executed in order one after another, until content is found in Umbraco that matches the pattern of the incoming url.

    You can create your own 'Content Finder' by creating a class that inherits IContentFinder, and implementing the 'TryFindContent' method, using the ContentFinderResolver at ApplicationStarting to add your Content Finder to the queue of Content Finders that ship by default.

    see: https://our.umbraco.com/documentation/reference/routing/request-pipeline/IContentFinder

    That said.... you may be able to achieve the pattern you are after by using the structure of your site, eg if in the root of your Umbraco site you have a top level 'Country' node, and then beneath that, multiple 'Language' nodes, (if you add the umbracoUrlName property to the language document type, you can set the portion of the url corresponding to them as the shorter language letter code).

    eg

    enter image description here

    and you can set the Url for the 'Country' via the Culture and Hostnames option:

    enter image description here

    but if you have a more complex scenario, eg when there is only one language in the country you don't have this pattern, or if sometimes there aren't actual pages for the content, but you want the url to fallback to the native language, then a custom IContentFinder is probably the way to go...

  • Anderson Moscarelli 3 posts 73 karma points
    Sep 12, 2018 @ 17:35
    Anderson Moscarelli
    0

    Hi Marc. Thanks. I' actually trying to build some endpoint where the raw ur like (myapi/getidfrolanguage/fr/en") l is give me content id of the node france/english

Please Sign in or register to post replies

Write your reply to:

Draft