Copied to clipboard

Flag this post as spam?

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


  • Rocoeh 65 posts 86 karma points
    Jul 18, 2012 @ 16:47
    Rocoeh
    0

    Iterating through ultimate picker

    Hi,

    I have a multi-node picker, it allows me to pick up to 3 nodes

    <umbraco:Item field="venuesPicker" runat="server" /> this gives me, 1702, 1712, 1743


    I would like to use this to iterate through and get the title so for example the aliasTitle, Sometimes there will be 3 other times 1 will be picked.

     

    Thanks,

     

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jul 18, 2012 @ 17:07
    Hendy Racher
    0

    Hi Rocoeh,

    If you have uComponents installed (or are using Umbraco 4.8 beta) there's a method in uQuery that'll return a collection of nodes from a CSV string:

    <ul>
      @{
        string venuesCsv = uQuery.GetCurrentNode().GetProperty<string>("venuesPicker"); 
        foreach (Node pickedNode in uQuery.GetNodesByCSV(venuesCsv)) 
        {    
          <li>@(pickedNode.GetProperty<string>("title"))</li>
        } 
      }
    </ul>

    HTH,

    Hendy

  • Rocoeh 65 posts 86 karma points
    Jul 18, 2012 @ 17:22
    Rocoeh
    0

    Hi,

     

    thanks that did not work put this directly in my template

     

    <ul
    <umbraco:Macro runat="server" language="cshtml">

      @{
        string venuesCsv = uQuery.GetCurrentNode().GetProperty<string>("venuesPicker");
        foreach (Node pickedNode in uQuery.GetNodesByCSV(venuesCsv))
        {    
          <li>@(pickedNode.GetProperty<string>("title"))</li>
        }
      }

    </umbraco:Macro>

            </ul>

    I get a macro load error

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jul 18, 2012 @ 17:28
    Hendy Racher
    0

    Hi Rocoeh,

    Have you referenced the namespaces ?  (if using uComponents you'll need: using uComponents.Core; and using uComponents.Core.uQueryExtensions; )

     

  • Rocoeh 65 posts 86 karma points
    Jul 18, 2012 @ 17:39
    Rocoeh
    0

    no luck either am trying the razor version

     

    <umbraco:Macro runat="server" language="cshtml">
    <ul>
      @{
      foreach (var x in Model.venuesPicker) {
      <li>@x.id</li>
    }
    </ul>
    </umbraco:Macro>

     

    but get the same error.

  • Rocoeh 65 posts 86 karma points
    Jul 18, 2012 @ 17:39
    Rocoeh
    0
  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 18, 2012 @ 18:24
    Jeavon Leopold
    1

    You can reference namspaces in inline Razor like this:

    <umbraco:Macro runat="server" language="cshtml">
    @using uComponents.Core;
    @using uComponents.Core.uQueryExtensions;

    @{
      var h1 = uQuery.GetCurrentNode().GetProperty<string>("pageTitleH1");
      <h1>@h1</h1>
    }

    </umbraco:Macro>

  • 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