Copied to clipboard

Flag this post as spam?

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


  • Jothipriya G 8 posts 110 karma points
    Feb 16, 2022 @ 05:40
    Jothipriya G
    0

    To get UnPublished Contents

    Hi Everyone,

    I'm new to umbraco. Here I have created a blog with 4 events here I have unpublished 2 of the events now in my website I can able to see the remaining two published events.

    Now I want to display the unpublished events in a separate page so that, I have modified the query like

    From

    @{
        .Where(x => x.IsVisible());
    }
    

    To

    @{
        .Where(x => x.InVisible());
    }
    

    I don't know whether it's correct or not???

    What I want to do to get the unpublished event (i.e., UnPublished contents from backoffice)?????????

    -Regards, Jothipriya G

  • Sören Deger 733 posts 2844 karma points c-trib
    Feb 16, 2022 @ 13:53
    Sören Deger
    0

    Hi Jothipriya,

    you can only get the unpublished content with contentservice:

    https://our.umbraco.com/Documentation/Reference/Management/Services/ContentService/index-v8

    https://our.umbraco.com/apidocs/v8/csharp/api/Umbraco.Core.Services.IContentService.html

    With the default razor syntax, you get only the IPublishedContent-Objects from nuCache.

    Hope this helps?

    Best regards, Sören

  • Jothipriya G 8 posts 110 karma points
    Feb 23, 2022 @ 15:39
    Jothipriya G
    0

    Regret for delayed. I Can't get the unpublished content still now??? Is there any other way???

  • Jannik Anker 48 posts 258 karma points c-trib
    Feb 24, 2022 @ 09:35
    Jannik Anker
    0

    If you really need to get unpublished content, Sörens answer - using the ContentService - is the only way. I still don't really understand why you need to get unpublished content, though, as that's not how you're supposed to use Umbraco :-/

    But okay. Have you tried getting the content using the ContentService? Did that not work? If not, how did it fail?

  • Jannik Anker 48 posts 258 karma points c-trib
    Feb 17, 2022 @ 12:55
    Jannik Anker
    0

    Maybe there's some confusion about what it means to publish/unpublish content as well? In my mind it doesn't make much sense to want to list unpublished content as it cannot be accessed anyway.

    Visible/Invisible is nothing to do with Published/Unpublished. An unpublished node doesn't exist in the cache that Umbraco normally uses.

    If we're talking actual events that have dates and can be in the future ("Visible") or in the past ("Invisible"), you shouldn't unpublish the past events. Instead, query by the date field(s) instead, like

    .Where(x => x.YourCustomEventDate < DateTime.Now);
    

    to get a list of past events and

    .Where(x => x.YourCustomEventDate >= DateTime.Now);
    

    to get a list of current or coming events.

    Apologies if I've misunderstood your predicament :-)

Please Sign in or register to post replies

Write your reply to:

Draft