Copied to clipboard

Flag this post as spam?

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


  • djscorch 67 posts 106 karma points
    Nov 13, 2011 @ 21:43
    djscorch
    0

    Is there a problem with DescendantOrSelf in 4.7.0?

    <div class="latest-mixes">
      <ul>

        @{
          var mixNode = @Model.DescendantOrSelf("MixArchive");
        }
      </ul>
    </div>


    Gives me the error Error loading Razor Script homeMixes.cshtml Cannot invoke a non-delegate type.

    Am i missing something?

  • UmbracoNewb 31 posts 53 karma points
    Nov 14, 2011 @ 13:37
    UmbracoNewb
    1

    Works for me in 4.7.1. Remember if you want a collection of nodes, then it's DescendantsOrSelf

  • djscorch 67 posts 106 karma points
    Nov 25, 2011 @ 14:15
    djscorch
    0

    I just want the one node, i'm having a similar issue in a 4.7.1 build.

    var mixNode @Model.DescendantOrSelf("MixArchive");

    doesn't seem to return anything. Could I see your syntax?

  • UmbracoNewb 31 posts 53 karma points
    Nov 25, 2011 @ 14:17
    UmbracoNewb
    0

    It's still DescendantsOrSelf with an "s" before Or :-)

  • djscorch 67 posts 106 karma points
    Nov 25, 2011 @ 14:36
    djscorch
    0

    Not according to Umbraco 4.7.1 Razor + DynamicNode Cheat Sheet it's not...

    http://our.umbraco.org/projects/developer-tools/razor-dynamicnode-cheat-sheet

  • Dav 44 posts 69 karma points
    Nov 25, 2011 @ 15:23
    Dav
    0

    djscorch, you are indeed right, the cheat sheet shows methods that simply do not exist in Umbraco source! However, I thought the method looked useful (and spent like 15mins trying to debug why it didn't work as expected) and so I implemented this using breadth first search. I've shared the patch on gist; after you recompile you need to replace umbraco.MacroEngines.dll with the improved version.

    Let me know if you encounter any problems, this was only briefly tested for our use case.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Nov 28, 2011 @ 21:11
    Sebastiaan Janssen
    1

    Depending on what you need, just do DescendantsOrSelf (WITH the "s") and add .First() or .Last() in the end. I wouldn't recommend customized versions of the Razor engine as it will block your upgrade path to newer versions of Umbraco.

  • UmbracoNewb 31 posts 53 karma points
    Nov 29, 2011 @ 08:55
    UmbracoNewb
    0

    djscorch maybe you could describe what you want to achieve?

  • djscorch 67 posts 106 karma points
    Nov 29, 2011 @ 10:01
    djscorch
    0

    I just wanted to select a specific node, using the nodeTypeAlias, seems like this is possible with DescendantsOrSelf and the .First().

    I'll give it a try and get back, at least I know I wasn't going crazy and DescendantOrSelf really doesn't work!

    Cheers guys.

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Nov 29, 2011 @ 10:03
    Michael Latouche
    0

    Hi djscorch,

    You can also try to remove the "@" in front of Model, since you already have an @ before the curly brackets:

    @{
          var mixNode = Model.DescendantOrSelf("MixArchive");
        }


    Cheers,

    Michael.

     

  • Dav 44 posts 69 karma points
    Nov 29, 2011 @ 10:45
    Dav
    0

    > I wouldn't recommend customized versions of the Razor engine as it will block your upgrade path to newer versions of Umbraco.

    Perhaps true, but we maintain a set of over a dozen little patches for our internal use and regularly apply them to newer versions of Umbraco. Plus Umb v5 is meant to be a whole different codebase which will trow all of them out the window anyway!

    Ps. A little odd that nForum does not have the "Quote" button... seems like a major shortcoming compared to other forums.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Nov 30, 2011 @ 18:03
    Sebastiaan Janssen
    0

    You wouldn't upgrade from v4 to v5 anyway.. 

    If you have fixes, I'm sure the umbraco team would be very happy to accept them, maybe you could try and get them into the core!

    Ps. This is not nForum. It's a custom forum written specifically for our.umbraco.

  • Dav 44 posts 69 karma points
    Dec 01, 2011 @ 09:19
    Dav
    0

    Exactly, that's what I meant when I said that v5 will throw all our patches out the window :-) We've been meaning to share them with the team for a while but never seem to have enough time to read up on the procedure required to do that... and resort to sharing them with the community in threads such as this one.

    Ps. I thought nForum was based on our.umbraco... but can see in page source that it's most likely powered by uForum. Shame about lack of quoting all the same ;-)

Please Sign in or register to post replies

Write your reply to:

Draft