Copied to clipboard

Flag this post as spam?

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


  • Jeroen Oostwouder 103 posts 299 karma points
    4 days ago
    Jeroen Oostwouder
    0

    How to get the right link in the RTE for the right content culture?

    I'm having a bit of trouble with the RTE in Umbraco 10, especially with the links within the content.

    I have a surfacecontroller to build an e-mail, using content from the RTE. This content is available in multiple languages. Getting this content is no problem.

    But the URL that's returned, when getting the content, is in the wrong culture.

    So, I have an RTE with some text and a link, pointed to the node /en/about-us/company. This page (about us/company) is also available in dutch and german.

    If I try to retrieve the text like this: Node.Value<IHtmlEncodedString>("Content", "en-US") I get the english content. But the link in my content is pointing to /over-ons/bedrijf (the dutch name of the selected node) instead of /en/about-us/company.

    Now people receiving the e-mail in english, will have a link to a dutch page.

    How can I make sure the link to the node is in the same culture as the content I'm trying to retrieve?

  • Afreed 47 posts 213 karma points
    3 days ago
    Afreed
    0

    Hi Jeroen,

    Have you tried with IVariationContextAccessor?

  • Jeroen Oostwouder 103 posts 299 karma points
    3 days ago
    Jeroen Oostwouder
    0

    I hadn't. I didn't even know about it.

    But it doesn't seem to make a difference either.

    It gets even weirder. If I do this:

    _variationContextAccessor.VariationContext = new VariationContext(cart.LanguageIsoCode);
    IHtmlEncodedString content = Node.Value<IHtmlEncodedString>("Content");
    

    The URL is gone. I get:

    <p>English <a href="#" title="Q&amp;A" data-anchor="#">Lorem</a> ipsum dolor sit amet, consectetur adipiscing elit. Mauris volutpat justo vitae
    

    The URL is replaced with a #

    If I do this:

    IHtmlEncodedString temp = Node.Value<IHtmlEncodedString>("Content", "en-US");
    
    _variationContextAccessor.VariationContext = new VariationContext(cart.LanguageIsoCode);
    IHtmlEncodedString content = Node.Value<IHtmlEncodedString>("Content", "en-US");
    

    So, getting the content, then settings the variationContextAxxessor and then getting the content again, I get english text but a dutch URL.

  • Afreed 47 posts 213 karma points
    3 days ago
    Afreed
    0

    It's working fine for me on v13.4.1, Should be the same on v10.

    var node = _context?.EnsureUmbracoContext()?.UmbracoContext.Content?.GetById(54164) as Home;
    
    const string culture = "da-dk"; 
    
    _variationContextAccessor.VariationContext = new VariationContext(culture);
    
    var node1 = _context?.EnsureUmbracoContext()?.UmbracoContext.Content?.GetById(54164) as Home;
    
  • Jeroen Oostwouder 103 posts 299 karma points
    3 days ago
    Jeroen Oostwouder
    0

    It works, as far as the content is concerned. But the link within my RTE content just turns to a # as soon as I use the VariantContextAccessor.

    It doesn't matter if I retrieve the node before or after the VariantContextAccessor.

  • Afreed 47 posts 213 karma points
    3 days ago
    Afreed
    0

    I had some RTE in my HOME doc type, it was pulling correct urls. That was me just checking the default culture and danish one and both were fine. I am not sure if it’s something with v10.

Please Sign in or register to post replies

Write your reply to:

Draft