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.
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.
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?
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
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.
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
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
Agree with Troels. You shouldn't see any unpublished nodes in your collection to start with.
is working on a reply...