Copied to clipboard

Flag this post as spam?

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

  • Sander van de Pas 73 posts 143 karma points
    Jun 14, 2018 @ 12:53
    Sander van de Pas

    Get all urls from all languages in Vorto for sitemap.xml

    What is the best way to get all pages/url's from a Vorto website? I need to create a custom sitemap.xml.

    Anyone an idea or suggestion?

    Thanks in advance.

    Grtz Sander

  • Nik 1517 posts 6705 karma points MVP 5x c-trib
    Jun 14, 2018 @ 14:34

    Hey Sander,

    In a recent project doing something similar I took the approach of having a custom controller for my XML site map.

    In the action I use this line to get all the domains for my root node (which has all the language elements)

    var domains = Services.DomainService.GetAssignedDomains(rootItem.Id, false).ToList();

    Then I call this recursive method:

    private void AddItemToList(ICollection<SitemapUrl> urlList, IPublishedContent item, IList<IDomain> domains)
            if(item.IsVisible() && item.TemplateId != 0 && item.DocumentTypeAlias.Equals("xmlSitemap") == false)
                urlList.Add(new SitemapUrl
                    Url = item.UrlWithDomain().Trim('/'),
                    LastModified = item.UpdateDate.ToString("yyyy-MM-dd"),
                    Alternatives = domains?.Select(d => new SitemapUrlAlternative
                            Language = d.LanguageIsoCode,
                            Url = $"{Request.Url.Scheme}://{d.DomainName.TrimEnd('/')}{item.Url}".TrimEnd('/')
            foreach(var child in item.Children())
                AddItemToList(urlList, child, domains);

    This works pretty well if you ask me :-)


Please Sign in or register to post replies

Write your reply to: