Copied to clipboard

Flag this post as spam?

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


  • Tarunjit 103 posts 146 karma points
    Aug 12, 2016 @ 08:28
    Tarunjit
    0

    Get All Published Pages Urls

    Hi All,

    We need to fetch urls of all the published pages in Umbraco.

    Can any one please help us on this?

    Regards

    Tarunjit Singh

  • Theo Paraskevopoulos 33 posts 122 karma points
    Aug 12, 2016 @ 09:27
    Theo Paraskevopoulos
    0

    Hi Tarunjit

    What do you mean by "fetch" - write them out in the screen? If so, you can probably use the Sitemap script

    Developer > Partial view macro files > Create new Select "Sitemap" from the list.

    This will give you a helper which draws a list, recursively with all nodes - easy to read and modify.

    Theo

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Aug 12, 2016 @ 18:52
    Dan Diplo
    0

    The following query will get all published nodes under the home page:

    Model.Content.AncestorOrSelf().Descendants()
    
  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Aug 13, 2016 @ 23:11
    Alex Skrypnyk
    0

    Hi Tarunjit,

    If you have few root nodes, you can use code like that:

    var allPublishedContent = new List<IPublishedContent>();
    
    foreach (var publishedContentRoot in Umbraco.TypedContentAtRoot())
    {
        allPublishedContent.AddRange(publishedContentRoot.DescendantsOrSelf());
    }
    

    Hope it will help you.

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft