Copied to clipboard

Flag this post as spam?

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


  • NiQ 24 posts 45 karma points
    Nov 14, 2011 @ 11:32
    NiQ
    0

    How do I get a MultiNodePicker value without a loop?

              <image>
                <MultiNodePicker>
                  <nodeId>1364</nodeId>
                </MultiNodePicker>
              </image>

    I have a page with Children who has a property called "image".

    I want to be able to do something like this:

    foreach (var page in Model.Children)
    {
      @var imageID = page.image[0].nodeId
    }

    Is it possible?

  • Rich Green 2246 posts 4008 karma points
    Nov 14, 2011 @ 11:50
    Rich Green
    0

    Hey NiQ,

    Have you seen this great package? http://our.umbraco.org/projects/developer-tools/cultiv-razor-examples

    I'm sure you'll find the answer in there.

    Rich

  • NiQ 24 posts 45 karma points
    Nov 14, 2011 @ 13:28
    NiQ
    0

    Hm haven't seen it before but I've installed it now but don't really get how this will help me.. :P

    EDIT: I just found some code wich were geting data from a MultiNodePicker but even there it was a foreach loop.. Im sure there must be a way to get this info without the loop.

  • Rich Green 2246 posts 4008 karma points
    Nov 14, 2011 @ 13:31
    Rich Green
    0

    Hi,

    It's a package that shows you how to get values by using Razor for all the uComponents and umbraco datatypes.

    Rich

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Nov 17, 2011 @ 19:48
    Sebastiaan Janssen
    0

    Why do you so badly not want to do it in a loop?? What if there's more than one node picked?

    You can probably do something like page.Image.First() or page.Image.First().nodeId (haven't been able to test this code yet) to get the first picked node.

  • NiQ 24 posts 45 karma points
    Nov 21, 2011 @ 15:39
    NiQ
    1

    Becuase I have set a limit to 1 so there is ALWAYS only one node. That's why I don't want to do a loop. :)

Please Sign in or register to post replies

Write your reply to:

Draft