Copied to clipboard

Flag this post as spam?

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


  • Ian Mone 8 posts 88 karma points
    Feb 23, 2018 @ 20:49
    Ian Mone
    0

    How to get RelatedLinks data/values (Umbraco 7.8.1)

    Hello,

    I just updated my Umbraco from 7.5 to 7.8, and the code I used to get my RelatedLinks data no longer works. I looked up an example on the documentation (https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/related-links) but it does not work.

    I can use the GetPropertyValues

    I've tried itemLinks.PropertyData.newWindow, itemLinks.PropertyData("newWindow"), itemLinks.GetPropertyValue

    Can anyone give any light on how to get the values from itemLinks?

    Thanks in advance.

    The values are there in the PropertyData

  • Daniel Chenery 119 posts 465 karma points
    Feb 23, 2018 @ 23:19
    Daniel Chenery
    1

    Is it related to property converters added in 7.6? https://our.umbraco.org/contribute/releases/760/

  • Ian Mone 8 posts 88 karma points
    Feb 26, 2018 @ 20:09
    Ian Mone
    0

    I think so, but I've read through and don't really understand what it is that I have to do to fix it. :(

  • Daniel Chenery 119 posts 465 karma points
    Feb 26, 2018 @ 20:33
    Daniel Chenery
    100

    Hi Ian,

    I haven't used RelatedLinks before, but property converters return an "Item" rather than an "Id".

    Take a Media Picker for example, before you would get the Id of that Media item and would have to used TypedMedia() to get your Media object, not it returns an IPublishedContent by default.

    Back to RelatedLinks... Here's the Property Converter in the Source Code

    It returns a JArray, so do you need to do itemLink.Value("link")?

    Alternatively, in your umbracoSettings.config file, you can add the following line

    <EnablePropertyValueConverters>false</EnablePropertyValueConverters>
    

    That should return the old behaviour.

  • Ian Mone 8 posts 88 karma points
    Feb 27, 2018 @ 18:48
    Ian Mone
    0

    Hi Daniel! Updating my config to not use property value converters worked! Thanks so much for the help.

  • David Zweben 265 posts 749 karma points
    Feb 24, 2018 @ 12:57
    David Zweben
    0

    What type is 'itemLink' returning as? Easy way to find out is to switch its 'var' to a specific type like 'IPublishedContent', and look at the error message if it throws one.

    Also, what error message do you get (if any) when you do itemLink.GetPropertyValue("newWindow")?

    Finally, you seem to be getting 'itemLink' and 'itemLinks' mixed up in your post; make sure that's not happening in your code too.

  • Ian Mone 8 posts 88 karma points
    Feb 26, 2018 @ 20:06
    Ian Mone
    0

    Hi David,

    The itemLink returns as a Umbraco.Web.RelatedLinks. I used to be able to do itemLink.newWindow, itemLink.caption, but since upgrading from 7.5 to 7.8, I can no longer access the data that way.

Please Sign in or register to post replies

Write your reply to:

Draft