Copied to clipboard

Flag this post as spam?

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


  • Dave 27 posts 79 karma points
    Oct 03, 2014 @ 12:14
    Dave
    0

    Umbraco returning unpublished nodes

    Hi all, new user here and im having a little trouble with Umbraco returning unpublished nodes.

    I am using version 7.1.6

    The structure of my site is fairly complex, I have a root node(1) which contains site settings, several subsections which each contain a number of pages(2) and themselves can have subpages(3)

    Now in my master template I have a little razor that outputs a dynamic menu, like so

    (2)
    (3)
    (3)
    (3)

    (2)
    (3)
    (3)
    (3)

    However, when I unpublish (2), it and its children are still included in my foreach loop and is outputted to the page, I believe there are two properties I can use here, Visible, and IsDraft however this always seem to return True and False respectively, im obviously not doing something right, and i expect to have made a mistake, but my limited knowledge makes tracking it down a little tough.

    Thanks in advance

  • Arjan Woldring 124 posts 231 karma points
    Oct 04, 2014 @ 13:32
    Arjan Woldring
    0

    Welcome Dave,

    It's correct what you said, the Visible property is available. But you need a property on your documenttype for it to work otherwise Visible will always be true.

    I would personally add a property to the documenttype like this: label: Hide in menu (for example) alias: umbracoNaviHide (for Visible property to work) datatype: true/false (for example)

    Now you have a hide in menu checkbox so you can use the visible property in your razor.

    Hope this helps you further.

  • Dave 27 posts 79 karma points
    Oct 05, 2014 @ 15:14
    Dave
    0

    Thanks for the reply, well it does help but doesnt that just add needless complexity when nodes (in my un-umbraco'd mind) could be removed / added to the front end output simply by publishing or unpublishing?

    Is there any way check whether a child node is published or not in a foreach loop?

    Thanks for your help

  • Troels Larsen 75 posts 280 karma points
    Oct 05, 2014 @ 15:24
    Troels Larsen
    0

    Hey Dave 

    How do you itterate over your nodes to print out you menu ?  Cause you should not see unpublished nodes in your publishedcontent colletion 

  • Arjan Woldring 124 posts 231 karma points
    Oct 05, 2014 @ 15:30
    Arjan Woldring
    0

    Agree with Troels. You shouldn't see any unpublished nodes in your collection to start with.

Please Sign in or register to post replies

Write your reply to:

Draft