Copied to clipboard

Flag this post as spam?

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


  • Jesse Andrews 159 posts 636 karma points
    Aug 08, 2019 @ 00:21
    Jesse Andrews
    0

    How do I get the name of a node for a specific language variant?

    I'm trying to generate a list of child names based on the language variant of the current page via a backoffice api call, but I've run into a road block getting the language variant names of the children that allow varying language by culture. As a test, I've tried using

    Model.Value("pageName", "en")
    

    but this doesn't work, likely because "pageName" is no longer a valid reference for the node name. I also tried a few other flavors of that like "@pageName," "nodeName" and "@nodeName," but had no success. None of these worked when the language code was removed either.

    I also tried getting at the name from the Cultures property, which does store the name. That property isn't publicly accessible though, so that is a no go as well.

    Any ideas on how to get the name for a specific language from a node?

  • Marc Goodson 1451 posts 9716 karma points MVP 5x c-trib
    Aug 08, 2019 @ 07:11
    Marc Goodson
    100

    Hi Jesse

    Looking here:

    https://github.com/umbraco/Umbraco-CMS/blob/27223738c6af045b637bb9944b53134e681ce5e5/src/Umbraco.Core/PublishedContentExtensions.cs#L48

    I'm thinking it might be a change to the usual Name property to allow a culture to be passed in...

    ... thinking something like this

    Model.Name("en-GB")
    

    might be what you are after?

    regards

    Marc

  • Jesse Andrews 159 posts 636 karma points
    Aug 08, 2019 @ 18:04
    Jesse Andrews
    0

    Thanks Marc,

    That's exactly what I was after. I didn't realize "Name" also doubled as a method call.

  • Marc Goodson 1451 posts 9716 karma points MVP 5x c-trib
    Aug 08, 2019 @ 19:36
    Marc Goodson
    0

    :-) t's only very recently that it has become one!

  • 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