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
    Feb 09, 2015 @ 13:27
    Tarunjit
    0

    Get Page Names For All Document Types

    Hi All,

    We want to fetch page names document type wise. Can any one please let us know the technique to use. Just for your information we are using Web Forms technique.

    We are thinking of using this through user control in our custom project, i.e. not through umbraco site. Can any one please let us know the Umbraco DLLs we should refer in our project to do this?

     

    Regards

    Tarunjit Singh

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 10, 2015 @ 12:36
    Jeroen Breuer
    0

    Hello,

    What version of Umbraco are you using? There are ways of doing this with the old and new api, but we first need to know the version you are using.

    Jeroen

  • Tarunjit 103 posts 146 karma points
    Feb 10, 2015 @ 12:53
    Tarunjit
    0

    Hi Jeroen,

    We are using Umbraco 7.2.1 version.

    Regards

    Tarunjit Singh

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 10, 2015 @ 13:00
    Jeroen Breuer
    1

    Hello,

    If you are on a view and only want to get all published pages per documen type:

    var results = Model.Content.AncestorOrSelf(1).Descendants("alias")

    On a controller that inherits from the SurfaceController or RenderMvcController:

    var results = CurrentPage.AncestorOrSelf(1).Descendants("alias");

    Also unpublished pages:

    var results = global::Umbraco.Core.ApplicationContext.Current.Services.ContentService.GetContentOfContentType(id);

    The id is the id of the document type.

    You need the Umbraco.Core.dll and umbraco.dll file. You might need so some extra dll's for references, but you'll get those messages while building.

    Jeroen

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 10, 2015 @ 13:04
    Jeroen Breuer
    0

    If you want to do it in a UserControl you should let your UserControl inherit from Umbraco.Web.UmbracoUserControl.

    You can also get the current page like this:

    protected static IPublishedContent CurrentPage
    {
        get { return UmbracoContext.Current.PublishedContentRequest.PublishedContent; }
    }

    Than you can use the second Controller example in a UserControl.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft