Copied to clipboard

Flag this post as spam?

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


  • SteveMid 25 posts 127 karma points
    Nov 10, 2016 @ 15:11
    SteveMid
    1

    umbracoNaviHide not working when used in a composition

    I have been reading how to use a umbracoNaviHide property to allow certain pages not to be included in a menu, which is functionality I would like on my site.

    I have been using the bog-standard example code, for example:

    <ul>
        @foreach (var page in CurrentPage.AncestorOrSelf(1).Children.Where("Visible")) 
       {
            </li>@page.Name</li>
        }
    </ul>
    

    ...and could not get it working at all. I've read loads of forum replies and checked everything they suggest (ensuring there are no trailing spaces etc. on my property alias) but it still would not work.

    I had initially added this property to a composition, as I wanted this feature to appear on every page on my site, but thought I'd delete it from there and add it manually to a single document type, on the off-chance that it was the property being in a composition causing the problem... and that works.

    Is this correct? Must I add the property to each and every document type, or is there a way I can use a composition?

    Thanks.

  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    Nov 10, 2016 @ 15:30
    Dennis Adolfi
    100

    Hi Steve.

    What version of Umbraco are you running?

    I´ve tried your problem in a 7.5.4 solution of Umbraco and it works fine with UmbracoNaviHide in compositions and the foreach statement you posted.

    This is most certanly an old bug thats been fixed in a newer version. Upgrade your Umbraco installation and that should fix it. Or, instead of using Visible, use .Where("umbracoNaviHide == false"). But obviusly upgrading is better.

    Ps. In your foreach statement, you have to closing li tags surrounding @page.Name. Just a heads up!

    Hope any of this was helpful!

  • SteveMid 25 posts 127 karma points
    Nov 10, 2016 @ 15:47
    SteveMid
    0

    Hi Dennis. Thanks for your response.

    I am on Umbraco version 7.5.3 assembly: 1.0.6092.24019

    Oops, I missed the typo - I was just giving an example of the sort of thing I've tried. My real menu is using a partial view based on this one

    I'll recreate the composition and try again using "umbracoNaviHide == false", but I think I tried that during my frantic try-anything phase earlier.

    Does Where("Visible") only check this property, or does it do any other magic such as check permissions or un-publish dates etc?

  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    Nov 10, 2016 @ 20:16
    Dennis Adolfi
    1

    I'm not sure but think it "only" checks the umbracoNaviHide but I could be mistaken.

    Could you try and setup again with the composition and re-publish the node and see if it doesn't work. Sounds very strange...

  • Andrew Vennells 16 posts 101 karma points
    Nov 11, 2016 @ 03:52
    Andrew Vennells
    2

    You should use the "umbracoNaviHide == false".

    https://our.umbraco.org/forum/developers/razor/22217-Visible

    If you're Model doesn't find the umbracoNaviHide property from your composition, try going back to the base document type and re-saving, then try going to the derived document type (consuming the composition) and re-save that. Then republish the node in the umbraco tree that you are testing. One way to make sure everything is published is use this link

    http://{your domain}/umbraco/dialogs/republish.aspx?xml=true

    then click on the republish entire site

  • SteveMid 25 posts 127 karma points
    Nov 11, 2016 @ 12:47
    SteveMid
    1

    I did everything suggested above (removed the property from all data types and compositions, switched to "umbracoNaviHide == false" and republished the entire site... and it now works!

    Sadly, I can't say for sure which of your suggestions did the trick, but I'm grateful for you help!

  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    Nov 11, 2016 @ 21:45
    Dennis Adolfi
    0

    Awesome! Glad that it worked out for you! Happy I could help!

    Have a great weekend!

    h5yr

Please Sign in or register to post replies

Write your reply to:

Draft