Copied to clipboard

Flag this post as spam?

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


  • Luis Pedro 21 posts 142 karma points
    Aug 14, 2019 @ 11:44
    Luis Pedro
    0

    Getting list of page variants to display other language options, per page

    Hey all,

    How can i get the number and list of page variants I have for a particular page , so that I can display other language options (in the top menu or body), considering that having each page in multiple languages is optional.

    So, in a page for DK, I want to show that that page has a translation to EN (automatically the other way around will work as well, same page, EN to DK) and in another page, I only show the DK version, because it was not yet translated and published into EN (or any other language).

    Thanks,

  • Shaishav Karnani from digitallymedia.com 330 posts 1537 karma points
    Aug 14, 2019 @ 13:21
    Shaishav Karnani from digitallymedia.com
    0

    Hi,

    We can use below code to fetch Multi Languages:-

    @foreach (var (culture, infos) in Model.Cultures)
    {
        <a href="@Model.GetUrl(culture)">@culture @infos.Name</a>
    }
    

    However, you need to ensure that domains are already setup as per below screenshot for them to work. enter image description here

    Further I would suggest to add Fallback language to provide better content flexibility.

    @Model.Value("pageTitle", "fr", fallback: Fallback.ToLanguage)

    This link is useful. https://our.umbraco.com/documentation/Getting-Started/Design/Rendering-Content/

    Hope this helps you.

  • Poornima Nayar 89 posts 186 karma points MVP c-trib
    Aug 21, 2019 @ 09:31
    Poornima Nayar
    0

    Hi Luis,

    This is what I did. I need to show a shore site name for each culture I have.

    @foreach (var (culture, infos) in Model.Cultures)
        {
        <li>
            <a href="@(Model.Url(culture))" class="active">@Model.AncestorOrSelf(1).Value("siteName", culture)</a>
        </li>
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft