Copied to clipboard

Flag this post as spam?

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


  • Yaco Zaragoza 80 posts 334 karma points
    Mar 08, 2024 @ 15:55
    Yaco Zaragoza
    0

    I am trying to build a directory on the backend that I can use across my site, Does any one have a good example or tutorial I can follow?

    I would like to create a ContentType called User Profiles Page that gets filled with User Profiles Items (Employee Name, Position, Bio, Etc)

    What I am trying to do is create a Block that has a list of all the profiles so I can select which onces show on each page.

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    26 days ago
    Alex Skrypnyk
    0

    Hi Yaco,

    You can use a folder with nodes that will store information you want to use on other pages with Content Picker or Multinode Tree Picker.

    Thanks, Alex

  • Yaco Zaragoza 80 posts 334 karma points
    24 days ago
    Yaco Zaragoza
    0

    I am doing some testing using the Multinode Tree Picker

    I created this tree structure

    Profiles

    Profile Item 01

    The Tree node allows Profile Item to be selected.

    I am using this code to display the items

    @{
        var typedMultiNodeTreePicker = Model.ProfileTree;
        foreach (var item in typedMultiNodeTreePicker)
        {
           <p><a href="@item.Url()">@item.Name</a></p>
        }
    }
    

    Is there a way for me to get to the properties of the item?

    I would like to get the EmployeeImage and EmployeePosition properties

  • Terence Burridge 1 post 92 karma points c-trib
    24 days ago
    Terence Burridge
    100

    Hi Yaco

    By default, pickers will usually return you a collection of the generic IPublishedContent type. However if you are using ModelsBuilder so already have strongly type models to cast to for the individual items, and are also quite sure that you're only ever going to be picking items of this type in the picker otherwise they will be filtered out, you should be able to get a strongly typed collection out instead by using the OfType< T >() method on the end to do something like:-

    foreach (var item in typedMultiNodeTreePicker.OfType<ProfileItem>())
    {
        <p><a href="@item.Url()">@item.Name</a></p>
        <p>@item.EmployeePosition</p>
    }
    

    Then you would be able to access the strong EmployeeImage and EmployeePosition properties on @item.

    Best regards, Terence

Please Sign in or register to post replies

Write your reply to:

Draft