Copied to clipboard

Flag this post as spam?

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


  • paul 5 posts 85 karma points
    Nov 17, 2015 @ 14:42
    paul
    0

    How to retrieve data of Related links on your own media type

    Hello,

    The question is in the title : How to retrieve data of Related links on your own media type

    So i build a media "Publications" who is composed of :

    • name(Textstring)
    • datepublication(Date picker)
    • file(Media picker)
    • link(Related Links)
    • thumbnails(Media picker)

    I don't success to retrieve data of Related Links in PartialView, I follow the example on doc page

    Look at my code :

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Newtonsoft.Json.Linq
    
    @{
        int publicationsFolderId = 0;
        if(@Culture == "en-US"){
            publicationsFolderId = 1195;
        }
        if(@Culture == "fr-BE"){
            publicationsFolderId = 1197;
        }
        if(@Culture == "nl-BE"){
            publicationsFolderId = 1198;
        }
    }
    
    <div class="card_header clearfix">
        <div class="card_header_title pull-left">@Umbraco.Field("#home-publications")</div>
        <small class="pull-right"><a href="">@Umbraco.Field("#home-more-publications")</a></small>
    </div>
    <div class="card_list">
    
        @foreach(var item in Umbraco.TypedMedia(publicationsFolderId).Children.OrderBy("datepublication desc").Take(3)){
    
            var dateFormat = string.Format("{0:dddd, d MMMM yyyy}", @item.GetPropertyValue("datepublication")); 
    
            <div class="card_list_item">
                <div class="card_block js-big-link">
                    <div class="card_block_description clearfix">
    
                        @{ 
                            IPublishedContent linkedFileUrl;
                            try { linkedFileUrl = Umbraco.TypedMedia(item.GetPropertyValue("file")); }
                            catch { linkedFileUrl = null; }
                         }  
    
                        @{
                            IPublishedContent image;
                            try { image = Umbraco.TypedMedia(item.GetPropertyValue("thumbnails")); }
                            catch { image = null; }
                        }
    
    
                        @foreach(var myLink in item.GetPropertyValue<JArray>("links")){
                            @myLink.Value("link")
                        }
    
                        <a href="@( linkedFileUrl != null ? linkedFileUrl.Url : null )" target="@( linkedFileUrl != null ? "_blank" : null )" class="pull-left">
                            @if (image != null)
                            {                                        
                                <img src="@image.Url?width=109&height=90&mode=crop" width="109" height="90" />
                            }
                        </a>
                        <a href="">@item.GetPropertyValue("name")</a><br>
                        Presentation - 
                    </div>
                </div>
            </div>  
        }
    </div>
    

    The compiler send this error message :

    Compiler Error Message: CS1928: 'Newtonsoft.Json.Linq.JToken' does not contain a definition for 'Value' and the best extension method overload 'System.Web.Mvc.Html.ValueExtensions.Value(System.Web.Mvc.HtmlHelper, string)' has some invalid arguments
    

    Can you help me for this ?

    Thanks in advance and sorry for my poor english !

  • 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