Copied to clipboard

Flag this post as spam?

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


  • James 251 posts 1169 karma points
    Sep 04, 2015 @ 11:12
    James
    0

    Ordering base on Parent Content picker

    Hello,

    I have a content picker on a parent node which has many child nodes.

    The content picker lets you select on of the children.

    In the view i want to order the children and set the one chosen in the content picker as first.

    Is there a way to do this?

    Cheers,

    J

  • James 251 posts 1169 karma points
    Sep 04, 2015 @ 11:35
    James
    0

    Trying something like:

    var node = Umbraco.Content(CurrentPage.contentPicker);
        selection = CurrentPage.Children.Where("Visible").OrderBy("@0", node.Id);
    

    This would be perfect but orderby doesn't work in this way :(

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Sep 04, 2015 @ 11:38
    Dennis Aaen
    100

    Hi James,

    What if you do some thing like this would this work for you.

    var node = Umbraco.Content(CurrentPage.contentPicker);
    selection = CurrentPage.Children.Where("Visible").OrderBy("Id == @0", node.Id);
    

    Hope this helps,

    /Dennis

  • James 251 posts 1169 karma points
    Sep 04, 2015 @ 11:38
    James
    0

    Ignore me:

    .OrderBy(node.Id);
    

    Sorted.

  • James 251 posts 1169 karma points
    Sep 04, 2015 @ 11:39
    James
    0

    Thanks Dennis

Please Sign in or register to post replies

Write your reply to:

Draft