Copied to clipboard

Flag this post as spam?

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


  • Rasmus Hummelmose 22 posts 72 karma points
    Mar 24, 2012 @ 15:30
    Rasmus Hummelmose
    0

    Failing to select descendants or self based on a where statement

    I've gotten around to installing Windows and setting up Visual Studio to run with my new Umbraco 5 installation. I am attemptning to select all nodes in my tree, based on whether or not a field is set to true. The field is called topNavigation. I want to use be able to use intellisense and at the moment I am fiddling with the following code:

    @inherits PartialViewMacroPage
    @using Umbraco.Cms.Web
    @using Umbraco.Cms.Web.Macros
    @using Umbraco.Framework
    
    @{
        // I want to get all nodes that have a field set to true.
        var root = @Model.CurrentPage.AncestorContentOrSelf().Last();
        var topNavigation = @root.DescendantContentOrSelf().Where("topNavigation = True");
    }
    
    <ul id="navigation">
        @{
            // Here I want to do a foreach on the result.    
        }
    </ul>

    The part where I use the where mthod fails because IEnumerable does not contain that method.

    Any ideas?

  • Rasmus Hummelmose 22 posts 72 karma points
    Mar 24, 2012 @ 15:39
    Rasmus Hummelmose
    0

    I tried to edit my topic to make my language clearer but edit throws and XSLT error and it won't let me delete the topic either.

  • Rasmus Hummelmose 22 posts 72 karma points
    Mar 24, 2012 @ 17:50
    Rasmus Hummelmose
    0

    Okay so I have it working perfectly with the following code

    http://pastie.org/3661229

    But that is using DynamicModel which does not provide any kind of autocompletion. It must be possible to do the same using the regular Model no?

  • Rasmus Hummelmose 22 posts 72 karma points
    Mar 24, 2012 @ 18:38
    Rasmus Hummelmose
    0

    It also seems that the above code causes my navigation children to be cached. When I uncheck the field "topNavigation" in the node, which comes from an inherit-only content-type, it doesn't refelct on my page when I refresh in a browser. It does however after a few minutes.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies