Copied to clipboard

Flag this post as spam?

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


  • Tony Lorentzen 69 posts 147 karma points
    Oct 28, 2019 @ 10:33
    Tony Lorentzen
    0

    Unpublished pages showing up in preview

    I've got a weird case where unpublished pages are showing up in the menu when I'm doing a preview of the frontpage of my site. How on earth is that happening when the page is completely unpublished?

    I'm using the following piece of code to get the top level menu items:

    Model.Root().Children.Where(x => x.IsVisible()).ToArray();
    
  • Steve Megson 150 posts 942 karma points MVP c-trib
    Oct 28, 2019 @ 15:06
    Steve Megson
    1

    The preview shows the latest version of all pages, including any unpublished pages. If that causes problems for things like menus, IsPublished() will tell you whether the page has a published version. So you might do something like this:

    Model.Root().Children.Where(x => x.IsVisible() && x.IsPublished()).ToArray();
    
Please Sign in or register to post replies

Write your reply to:

Draft