Copied to clipboard

Flag this post as spam?

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


  • Tom Cowling 142 posts 340 karma points
    Jan 14, 2020 @ 15:58
    Tom Cowling
    0

    Unpublished items showing

    I'm not sure what I'm doing wrong here, but for some reason unpublished items are showing in my list. It's a really simple macro that just shows all news items.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using Umbraco.Core.Models.PublishedContent
    @using Umbraco.Web
    
    
    
    @{  var selection = Model.Content.ChildrenOfType("newsItem")
        .Where(x => x.IsVisible())
        .OrderByDescending(x => x.Value<DateTime>("datePublished"))
        .ToArray();}
    
    @if (selection.Length > 0)
    {
            foreach (var item in selection)
            {
                    <p><strong><a href="@item.Url">@item.Value("title")</a></strong><br />
                    <span class="text-muted">@(item.Value<DateTime>("datePublished").ToString("ddd, dd MMMM yyyy"))</span></p>
    
            }
    }
    

    Am I missing something in my .Where?

  • Amir Khan 1020 posts 2120 karma points
    Jan 14, 2020 @ 18:53
    Amir Khan
    0

    That looks fine but have you tried to republish the entire site by right clicking on the content folder to rebuild the cache?

  • Tom Cowling 142 posts 340 karma points
    Jan 14, 2020 @ 19:58
    Tom Cowling
    0

    I couldn't see that when I right clicked, but found the following under the settings tab. I clicked every one of them, but didn't have any success:

    Published cache page

  • Tom Cowling 142 posts 340 karma points
    Jan 14, 2020 @ 20:01
    Tom Cowling
    0

    I tried this too. Also no luck. Publish with descendants

  • AddWeb Solution Pvt. Ltd 43 posts 197 karma points
    Jan 16, 2020 @ 05:54
    AddWeb Solution Pvt. Ltd
    0

    Hello,

    1.What does it show for published date ? for the non published items. 2. did the news items , published and then unpublished?

  • Tom Cowling 142 posts 340 karma points
    Jan 17, 2020 @ 14:43
    Tom Cowling
    0

    Some of the items are brand new and never been published. Some of the items were published then unpublished. It's the same for both..

  • Tom Cowling 142 posts 340 karma points
    Jan 17, 2020 @ 14:55
    Tom Cowling
    0

    example of unpublished item

    Here's a screenshot of all the data for one of the items showing.

    There is no link to the item in the list as it's unpublished and just goes to a #, but it's on the list.

    Render of items

  • Tom Cowling 142 posts 340 karma points
    Jan 17, 2020 @ 16:37
    Tom Cowling
    0

    If I name the node to start from explicitly, it gets rid of the unpublished ones.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using Umbraco.Core.Models.PublishedContent
    @using Umbraco.Web
    
    
    @{
        var selection = Umbraco.Content(Guid.Parse("43c3def7-83c0-42f0-a72d-641bfd79c427"))
         .ChildrenOfType("newsItem")
        .Where(x => x.IsVisible())
        .OrderByDescending(x => x.Value<DateTime>("datePublished"))
        .ToArray();
    }
    
    @if (selection.Length > 0)
    {
            foreach (var item in selection)
            {
                    <p><strong><a href="@item.Url">@item.Value("title")</a></strong><br />
                    <span class="text-muted">@(item.Value<DateTime>("datePublished").ToString("ddd, dd MMMM yyyy"))</span></p>
    
            }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft