Copied to clipboard

Flag this post as spam?

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


  • Allie 26 posts 116 karma points
    Jul 30, 2021 @ 17:16
    Allie
    0

    GroupBy Issue

    Hey everybody, I'm new in umbraco, so can sb help me ?..

    enter image description here

                                   @foreach(var subitem in item.Children)
                                   {
    
                                        List<string> categories = subitem.Pluck("category");
                                         foreach(var category in @categories.Distinct()) {
                                             <p>@category</p>
                                              <a href="@subitem.Value("contentLink")" title="@subitem.Value("title")">@subitem.Name</a>
                                            }  
                                   }
    

    Kind regards :)

  • Søren Gregersen 441 posts 1884 karma points MVP 2x c-trib
    Jul 30, 2021 @ 18:09
    Søren Gregersen
    100

    Hi,

    What should Pluck do? Is that something from Rails / ActiveRecord?

    If you have defined "category" as a TextBox, you could get the "category" as a string, with subitem.Value<string>("category"). If it is a MultiNodeTreePicker, you can get the value as a list of picked nodes - subitem.Value<IEnumerable<IPublishedContent>>("category")

    There is a description of all the built in types here https://our.umbraco.com/documentation/Fundamentals/Backoffice/Property-Editors/Built-in-Property-Editors/

    HTH :)

Please Sign in or register to post replies

Write your reply to:

Draft