Copied to clipboard

Flag this post as spam?

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


  • MB 262 posts 914 karma points
    Oct 21, 2020 @ 16:50
    MB
    0

    'IPublishedContent' does not contain a definition for 'GetPropertyValue'

    Hi everyone,

    I followed this guide: https://codeshare.co.uk/blog/how-to-create-a-carousel-in-umbraco-using-nested-content-and-bootstrap/ to implement a slideshow made as a Nested Content in a Composition.

    The following line fails:

    IEnumerable<IPublishedContent> carousel = Umbraco.AssignedContentItem.GetPropertyValue<IEnumerable<IPublishedContent>>("slideshowDoc");
    

    The alias is taken from my doc type: enter image description here

    The error I get:

     'IPublishedContent' does not contain a definition for 'GetPropertyValue' and no accessible extension method 'GetPropertyValue' accepting a first argument of type 'IPublishedContent' could be found (are you missing a using directive or an assembly reference?)
    

    I have tried to do some research and attempted the advices given in: https://github.com/umco/umbraco-nested-content/blob/develop/docs/assets/pdf/Nested-Content--Developers-Guide-v1.0.pdf but with no success unfortunately.

    Do you guys have any advice?

  • Anzal 11 posts 81 karma points
    Oct 21, 2020 @ 17:28
    Anzal
    0

    Hi, If you are using Umbraco 8 the syntax for fetching values is different it will be like

    var carousel = item.Value<IEnumerable<IPublishedContent>>("slideshowDoc", fallback: Fallback.ToLanguage, defaultValue: null);
    

    Above can be used for fetching media and node values, if its a nested content type element then the syntax will be

    var carousel  = item.Value<IEnumerable<IPublishedElement>>("slideshowDoc", fallback: Fallback.ToLanguage, defaultValue: null);
    

    Hope that helps.

  • Karen Worth 44 posts 137 karma points
    16 days ago
    Karen Worth
    0

    item. ?

Please Sign in or register to post replies

Write your reply to:

Draft