Copied to clipboard

Flag this post as spam?

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


  • Warren Harding 132 posts 275 karma points
    Feb 22, 2023 @ 08:55
    Warren Harding
    0

    Retrieving elements from the target of a content picker

    I've been going around in circles with this one, and was hoping someone could assist please.

    I am attempting to reference a "thumbnailImage" element on the page that is being selected from a content picker - how do I do this?

    Thank you

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Feb 22, 2023 @ 10:02
    Dave Woestenborghs
    0

    Hi Warren,

    Where are you trying to do this ? Can you tell us a bit more for your setup.

    • Umbraco version
    • Models builder mode

    Can you show us some example code of what you have so far.

    Dave

  • Warren Harding 132 posts 275 karma points
    Feb 23, 2023 @ 03:59
    Warren Harding
    0

    Thanks for getting back to me Dave, I'm running Umbraco 10.4 (now, was 10.3 yesterday) and using models mode SourceCodeAuto

    I am trying to tackle this in the partial for a block list component , which looks like this currently:

    @inherits UmbracoViewPage<BlockListSection>
    @using Umbraco.Cms.Core.Models;
    @using Umbraco.Cms.Core.Services;
    @inject IContentService Services;
    @{
        var content = (MyPublishedModel)Model.Block.Content;
        var contentService = Services;
    
        var udiAsString1 = content.Prev.Udi.ToString();
        var guid1 = Guid.ParseExact(udiAsString1.Substring(udiAsString1.Length - 32), "N");
        var content1 = contentService.GetById(guid1);
    
        var thumbnailImage = content1.Properties["thumbnailImage"].Values;
        var thumbnailImage2 = content1.Properties["thumbnailImage"].GetValue();
    
        var breakPoint = 1;
    }
    

    Ideally I would like to access the thumbnail variables as strongly typed MediaWithCrops but I'm not sure how to do that.

    Thanks again,

    Warren

  • Warren Harding 132 posts 275 karma points
    Feb 23, 2023 @ 04:33
    Warren Harding
    0

    I might have overcomplicated this by using Umbraco.MultiUrlPicker rather than Umbraco.MultiNodeTreePicker

    However, I would be keen to know how to bind the above too if you can please.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Feb 23, 2023 @ 08:07
    Dave Woestenborghs
    0

    Hi Warren,

    Can you post the code for BlockSection and MyPublishedModel ?

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft