Copied to clipboard

Flag this post as spam?

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


  • Rihab 104 posts 388 karma points
    Feb 04, 2019 @ 07:16
    Rihab
    0

    get content picker value from child page

    Hi guys,

    I'm facing a problem...... I have a page with children, the children have a content picker... what I want to get is : the image in the page that selected in the content picker for each child page.

    P.S: can only choose one page in the content picker.

    what i achieved is :

        IPublishedContent currentScene = Umbraco.TypedContent(CurrentPage.Id);
        IEnumerable<IPublishedContent> Pins = currentScene.Children();
     foreach (var pin in Pins)
                 {
                     var Thumbid = @pin.GetPropertyValue("pinPicture");
                     var Thumburl = Umbraco.Media(Thumbid.ToString()).Url;
                     <img id="@pin.Name  -thumb" crossorigin="anonymous" src="@Thumburl">
                     var typedMultiNodeTreePicker1 = @pin.GetPropertyValue("link");
                     var page = Umbraco.Content(@typedMultiNodeTreePicker1);
    
                     <img id="@page.Name" crossorigin="anonymous" src="">
    
    
             }
    

    the typedMultiNodeTreePicker1 is the node id but i can't get the name on any values from it ..... can someone help me.

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Feb 04, 2019 @ 09:07
    Nik
    100

    Hi ٌ

    Multi Node Tree Pickers return a value of IEnumerable

    Also, you are jumping between dynamics and typed content which isn't very good. You should try and stick with TypedContent.

    Try the following:

    var typedMultiNodeTreePicker1 = pin.GetPropertyValue<IEnumerable<IPublishedContent>>("link");
    var page = typedMultiNodeTreePicker1.FirstOrDefault();
    
    if(page != null)
    {
         <img id="@page.Name" crossorigin="anonymous" src="">
    }
    

    Thanks

    Nik

Please Sign in or register to post replies

Write your reply to:

Draft