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 88 posts 363 karma points
    Mar 08, 2024 @ 15:55
    Yaco Zaragoza
    0

    Re-usable content

    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 6175 posts 24186 karma points MVP 8x admin c-trib
    Mar 27, 2024 @ 17:38
    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 88 posts 363 karma points
    Mar 29, 2024 @ 14:10
    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 6 posts 118 karma points MVP c-trib
    Mar 29, 2024 @ 18:01
    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