Copied to clipboard

Flag this post as spam?

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


  • Danny 4 posts 85 karma points
    Nov 12, 2019 @ 10:43
    Danny
    0

    How to get Name or Url of an IPublishedContent with a specific culture?

    I want to know how to get the Url or Name of an IPublishedContent with a specific culture.

    For example, you can get a property value of a specific culture like this

    string description = content.Value<string>("description", "da-dk");
    

    But i cant get the Name or Url of the IPublishedContent because they are properties and dont have any CultureInfo argument that i can pass in.

    Anyone know how to do it?

    Thanks in advance

  • Bo Jacobsen 438 posts 1818 karma points
    Nov 12, 2019 @ 11:10
    Bo Jacobsen
    101

    Hi Danny.

    I think that you have to upgrade to 8.1.1 (i am not 100% sure of the version) in order to do Model.Name("da-dk") and Model.Url("da-dk", UrlMode.Absolute)

  • Patrick van Kemenade 69 posts 263 karma points
    Nov 12, 2019 @ 11:11
    Patrick van Kemenade
    1

    Dear Danny,

    I spend out trying to figure out something similar. I have a website in both Dutch and English and each page is Multilanguage. On the Dutch pages I want to automatically include the link to the English version and visa versa.

    @Model.Url("nl", UrlMode.Absolute)

    @Model.Url("en-us", UrlMode.Absolute)

    This worked for me, hopes this helps you, good luck!

    Regards, Patrick

  • Danny 4 posts 85 karma points
    Nov 12, 2019 @ 12:23
    Danny
    1

    Thanks, it worked! :)

    One note is that you must declare these namespaces, otherwise they wont appear

    using Umbraco.Core;
    using Umbraco.Web;
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies