Copied to clipboard

Flag this post as spam?

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


  • Jesper Weber 54 posts 170 karma points c-trib
    Apr 14, 2023 @ 12:27
    Jesper Weber
    0

    MultiUrlPicker does not return culture specific urls

    Umbraco Version: 11.2.2

    I have a multi-lingual site containing:

    • Content page that varies by culture
    • Home page the varies by culture and has a multiUrlPicker property that also varies by culture
    • The multiUrlPicker property on the home page points to the content page

    In Umbraco the property on my home page looks like the following (on en-US and da-DK version):

    enter image description here

    enter image description here

    I see the name and the url of the node referenced is correct.

    However in my code I have the property and when I call property.GetValue("some culture code") the links that is returned always has the url value from the default language and not the url from the culture I'm passing in as argument to the GetValue method.

    The name property is in the correct culture.

    See examples below:

    culture is en-us

    enter image description here

    culture is da-dk

    enter image description here

    Is it me doing something wrong or is this an error in Umbraco?

  • Jesper Weber 54 posts 170 karma points c-trib
    Jun 21, 2023 @ 09:29
    Jesper Weber
    100

    Ahh, I figured out the reason for this :-)

    Parsing on the culture to property.GetValue("some culture") does give you the content for the right culture. I could see that because I ran in to the same issue with links in the RTE editor. I got the english text and the danish text depending on the culture I was parsing in.

    But, I was not aware that in Umbraco when you are using Vary by culture it's not possible to link from a page in one culture to a page in another culture.

    The backoffice doesn't give the editors the option to choose culture when creating a link and also Umbraco only stores the id of the page you are linking too and not the culture.

    This means that when you pull up a content node in the API, the link you have on that node to another page will always be a link to the same culture as the content node you pulled up from the API.

    In my case I was always loading the english version of the node and because of the the links I resolved was always to the english version of a page even though I was passing in another culture to property.GetValue("...").

    I needed to set the variationContext before loading the node in order to load the node in the right culture and then everything was working.

    _variationContextAccessor.VariationContext = new VariationContext(job.Culture);
    
Please Sign in or register to post replies

Write your reply to:

Draft