Copied to clipboard

Flag this post as spam?

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


  • Darren Wilson 238 posts 646 karma points
    Aug 23, 2016 @ 14:07
    Darren Wilson
    0

    Listing Media Picker Items names from MemberTypes

    Hi Folks,

    I've got a macro that lists MediaPicker items associated with a Member Type (listed below). I need to output the Node Name of any media. The the moment <h3>imageItem.name</h3> just outputs the text imageitem.name not the media item title - any ideas what I need to change this too to display the media item name?

    Thanks

    Darren

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using System.Web.Mvc.Html
    @using ClientDependency.Core.Mvc
    @using Umbraco.Web
    @using Umbraco.Web.Controllers
    
    @{
    var profileModel = Members.GetCurrentMemberProfileModel();
    
    Html.EnableClientValidation();
    Html.EnableUnobtrusiveJavaScript();
    Html.RequiresJs("/umbraco_client/ui/jquery.js");
    Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js");
    Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");
    
    var success = TempData["ProfileUpdateSuccess"] != null;
    }
    
    
    @Html.RenderJsHere()
    
    @if (Members.IsLoggedIn() && profileModel != null)
    
    {   
    
    using (Html.BeginUmbracoForm<UmbProfileController>("HandleUpdateProfile", null, new { id = "updateProfileForm" }))
        {
            var member = Members.GetByUsername(profileModel.UserName);
    
        if (member.HasValue("documentsMember"))
            {
                var imagesList = member.GetPropertyValue<string>("documentsMember").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
                var imagesCollection = Umbraco.TypedMedia(imagesList).Where(x => x != null);
    
                foreach (var imageItem in imagesCollection)
                    {    
                        <div class="file-customer">
                            **<h3>imageItem.name</h3>**
                        </div>
                        <div class="file-icon"><a href="@imageItem.Url" target="_blank"><img src="../media/1025/untitled-1.png"></a></div>
                    }                                                               
            }
    
    
    
    }       
    
    }
    
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 23, 2016 @ 14:43
    Dennis Aaen
    100

    Hi Darren,

    You need to add @ in front of it to tell that you want the Razor engine to pass it.

    So try

    <h3>@imageItem.Name</h3>
    

    Hope this helps,

    /Dennis

  • Darren Wilson 238 posts 646 karma points
    Aug 23, 2016 @ 14:50
    Darren Wilson
    0

    Cheer Dennis, the answer was staring me in the face ha ha.

    Darren

Please Sign in or register to post replies

Write your reply to:

Draft