Copied to clipboard

Flag this post as spam?

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


  • Ben 19 posts 109 karma points
    Jun 26, 2018 @ 10:46
    Ben
    0

    Reusable blocks and showing multiple

    Hi All,

    Im working on a reusable block picker for a sidebar of cta's. Im also working quite heavily with the grid through a possibly original misguided path i took when creating the site.

    So ive created a content type of reusable grid blocks where users can create different types of grid content. I then created a doctype of sidebarCTA with a content picker and used something like this:

                @{
                    var sidebarCTA = Model.Content.GetPropertyValue<IPublishedContent>("sidebarCta");
                }
                @if (sidebarCTA != null)
                {
                    @Html.GetGridHtml(sidebarCTA, "content")
                }
    

    This works fine and shows the selected bit of content. The client wants to select multiple rather than putting multiple CTA's in the grid.

    So i thought about using the Multi-node tree picker, but not sure if this is the best option, it allows them to select the relevant CTA's but i cant get the selected to render.

    Can anyone offer any advice?

  • Frans de Jong 550 posts 1862 karma points MVP 4x c-trib
    Jun 28, 2018 @ 19:52
    Frans de Jong
    0

    If you use the MNTP you can indeed pick and sort multiple sidebar grid instances.

    The code could look something like this:

            @{
                IEnumerable<IPublishedContent> sidebarCTAList = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("sidebarCta");
            }
            @if (sidebarCTAList.Any())
            {
               foreach(IPublishedContent sidebarCTA in sidebarCTAList )
               {
                  @Html.GetGridHtml(sidebarCTA, "content")
               }
            }
    

    Not the most elegant/efficient way but it should work.

  • Ben 19 posts 109 karma points
    Jun 29, 2018 @ 21:36
    Ben
    0

    Thanks for the reply Frans, looks useful. Im out of the office for a few days now but will get onto trying this as soon as im back. Will let you know how i get on.

  • Frans de Jong 550 posts 1862 karma points MVP 4x c-trib
    Jun 30, 2018 @ 17:49
    Frans de Jong
    0

    No problem. Glad to help.

  • 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