+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / .ThatArePublished() Returns UnPublished pages

.ThatArePublished() Returns UnPublished pages

5 posts, 0 answered
  1. Jonathan
    Jonathan avatar
    9 posts
    Registered:
    09 Apr 2013
    06 Jan
    Link to this post

    I expect the following to return the published pages that have a parent with a specific id, but it doesn't behave as expected. It returns unpublished pages along with published ones:

    DataSet = App.WorkWith().Pages().LocatedIn(PageLocation.Frontend).Where(p => p.Parent.Id == currentNode.Id).ThatArePublished().Get().OrderBy(p => p.Ordinal).ToList();

    To only display published pages, I have to get into PageData instead:

    DataSet = App.WorkWith().Pages().LocatedIn(PageLocation.Frontend).Where(p => p.Parent.Id == currentNode.Id && p.GetPageData().Visible).Get().OrderBy(p => p.Ordinal).ToList();

    Is this expected? Is there a better method to get only published pages?

    I would expect "ThatArePublished()" to only return pages "that are published".

    Thanks in advance

    Jonathan

  2. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    24 Nov 2016
    12 Jan
    Link to this post
    Hello,

    You should check whether the page is deleted the following way:
    Copy Code
    var newCulture = new CultureInfo("en");
                var pagesFl = App.WorkWith().Pages()
                                        .LocatedIn(PageLocation.Frontend)
                                        .ThatArePublished()
                                        .ThatAreForLanguage(newCulture)
                                        .Get()
                                        .Where(p => p.IsDeleted == false)
                                        .OrderByDescending(x => x.LastModified).ToList();

    This will return the correct pages - the ones you expect excluding the deleted.


    However, the api is actually really getting published items, though some of them are in the recycle bin and are deleted. The published state is part of the workflow and the visibility (Visible property for content items) or deleted is more part of the content lifecycle.
    There is a feature request for a way to get the published and visible items with one method call. You can review it in our portal here.


    Regards,
    Nikola Zagorchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Jonathan
    Jonathan avatar
    9 posts
    Registered:
    09 Apr 2013
    13 Jan in reply to Nikola Zagorchev
    Link to this post

    I don't think you read my post correctly. The problem is not that the query is returning *deleted* pages (which you address in your solution), the problem is that the query is returning *unpublished* pages, which I would not expect, as the method is titled "ThatArePublished()"

     

  4. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    24 Nov 2016
    14 Jan
    Link to this post
    Hi Jonathan,

    Please, excuse me for the misunderstanding.

    I was able to reproduce the issue on my end. I am currently verifying it with our QAs and will share with the community whether this is a bug.
    This issue is related:
    http://feedback.telerik.com/Project/153/Feedback/Details/134445-filter-pages-does-not-work-correctly-when-using-published-filter

    In the meantime, please, use the workaround you have found.

    Regards,
    Nikola Zagorchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  5. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    24 Nov 2016
    14 Jan
    Link to this post
    Hi,

    Here is the bug item in our portal:
    http://feedback.telerik.com/Project/153/Feedback/Details/180295-fluent-api-pages-thatarepublished-returns-unpublished-and-draft-pages
    I have updated your Telerik points.

    Regards,
    Nikola Zagorchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
5 posts, 0 answered