Copied to clipboard

Flag this post as spam?

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


  • Kerri Mallinson 113 posts 497 karma points
    Aug 08, 2014 @ 15:43
    Kerri Mallinson
    0

    Help with MultiNodeTreePicker

    Hi,

    I'm new to all this and was wondering if anyone can help or point me in the right direction?

    I'm using V7.1.4

    On my homepage I want to display a sidebar with some Case Studies on it, i have added MNTP to the Homepage and selected the Case Studies I want to display, I'm trying to get properties from the Case Study page to display on the Homepage, I can get all the properties i need but only the node id of the image and not the actual image ("thumb"), the code i have is;

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @{

    var workList = CurrentPage.relatedWork.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

        var workCollection = Umbraco.Content(workList);

        foreach (var work in workCollection)

        {

            <p>@work.Id</p>

    <p>@work.Name</p>

    <p><a href="@work.Url">@work.caseStudyTitle</a></p>

    <p>@work.intro</p>

    <p>@work.thumb</p>

        }

     

    Thanks

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Aug 08, 2014 @ 16:01
    Jeavon Leopold
    100

    Hi Kerri,

    Welcome to Our!

    Try this:

    if (work.HasValue("thumb")){                                         
        var dynamicMediaItem = Umbraco.Media(work.thumb);
        <img src="@dynamicMediaItem.Url" alt="@dynamicMediaItem.Name"/>
    }
    

    Jeavon

  • Kerri Mallinson 113 posts 497 karma points
    Aug 08, 2014 @ 16:07
    Kerri Mallinson
    0

    Thanks Jeavon, that works :)

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Aug 08, 2014 @ 16:10
    Jeavon Leopold
    0

    Perfect, I just corrected a mistake in the HasValue("mainImage"), should be HasValue("thumb") for you

  • 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