Copied to clipboard

Flag this post as spam?

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


  • Matt 353 posts 825 karma points
    Oct 24, 2019 @ 09:11
    Matt
    0

    Display image from nested content

    Hello,

    I have a nested view with a title and a media picker, what I want to do is display the nested view in a list with.

    my code below works sort of, with the fact that I got the nested content being displayed. however its not picking up the document from media picker.

     @inherits Umbraco.Web.Mvc.UmbracoViewPage
    
    
    
     <div class="coltest w-row">
                            <div class="col0 w-col w-col-6 w-col-small-6 w-col-tiny-6">
                                <div class="blue-box">
                                    <h3 class="table-heading">Description</h3>
                                </div>
                            </div>
                            <div class="col0 w-col w-col-6 w-col-small-6 w-col-tiny-6">
                                <div class="blue-box right-line">
                                    <h3 class="table-heading">Download</h3>
                                </div>
                            </div>
                        </div>
    
                        @{
                         var accordionList = Model.Value<IEnumerable<IPublishedElement>>("matttest");
                        }
    
                        @foreach (var panel in accordionList.Where(x => x.IsVisible()))
                        {
    
    
                        <div class="coltest w-row">
                            <div class="w-col w-col-6 w-col-small-6 w-col-tiny-6">
                                <div class="div-block-21 w-clearfix">
    
    
    
                                    <div class="folder-title"><a href="@panel.Value("boardPaperFile")" class="footer-title-link">@panel.Value("boardPaper")</a></div>
                                </div>
                            </div>
                            <div class="w-col w-col-6 w-col-small-6 w-col-tiny-6">
    
                                <div class="div-block-21"><a href="#" class="w-inline-block"><img src="~/images/writing.png" width="34" alt="" class="file-image"></a></div>
    
    
                            </div>
                        </div>
                        }
    

    Thanks in advance

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Oct 24, 2019 @ 12:56
    Nik
    0

    Hi Matt,

    So, a Media Picker will most likely be returning an IPublishedContent

    So, you might need to do the following:

    @{
       var paperFile = panel.Value<IPublishedContent>("boardPaperFile");
       if(paperFile != null)
       {
            <div class="folder-title"><a href="@paperFile .Url" class="footer-title-link">@panel.Value("boardPaper")</a></div>
       }
     }
    

    Hope it helps.

    Nik

  • Matt 353 posts 825 karma points
    Oct 24, 2019 @ 13:01
    Matt
    0

    Hello Nik,

    Thanks for the reply, that seems to have it working!

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft