Copied to clipboard

Flag this post as spam?

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


  • Jan Hansen 7 posts 27 karma points
    Aug 17, 2015 @ 12:32
    Jan Hansen
    0

    HasVortoValue not working on a media item

    Hi

    Umbraco 7.2.6 and Vorto 1.4

    I have added "description" as a Vorto-wrapped TextString on a custom media type called vimeovideo. Hence, I can specify a description for a video in multiple languages. There is also a downloadLink, which is not wrapped with vorto.

    When I want to show a list of videos, I use this

    var productVideosList =  Model.Content.GetPropertyValue<string>("videos").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
    var productVideosCollection = Umbraco.TypedMedia(productVideosList).Where(x => x != null);
    foreach (var productVideo in productVideosCollection)
    {
        if (productVideo.HasValue("downloadLink"))
        {
            var destinationUrl = productVideo.GetPropertyValue<string>("downloadLink");
            var desc = productVideo.HasVortoValue("description") ? productVideo.GetVortoValue("description") : productVideo.Name;
            <li><a href="@destinationUrl" target="_blank"><i class="fa fa-video-camera"></i> @desc </a></li>
        }
    
    }
    

    But I get the error: CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'HasVortoValue' and no extension method 'HasVortoValue' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found

    What am I doing wrong here? Probably something with the productVideo instance not being of the correct type, but I can't figure it out.

    Any ideas?

    Best regards Jan

  • Jan Hansen 7 posts 27 karma points
    Aug 18, 2015 @ 09:31
    Jan Hansen
    0

    OK - so I started fiddling around with casting to IPublishedContent, and suddenly the posted code above works. No errors. Very, very strange. Can this somehow be related to "publishing" a media item?

Please Sign in or register to post replies

Write your reply to:

Draft