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 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
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.
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.
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.
Is it related to property converters added in 7.6? https://our.umbraco.org/contribute/releases/760/
I think so, but I've read through and don't really understand what it is that I have to do to fix it. :(
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 usedTypedMedia()
to get your Media object, not it returns anIPublishedContent
by default.Back to RelatedLinks... Here's the Property Converter in the Source Code
It returns a
JArray
, so do you need to doitemLink.Value("link")
?Alternatively, in your
umbracoSettings.config
file, you can add the following lineThat should return the old behaviour.
Hi Daniel! Updating my config to not use property value converters worked! Thanks so much for the help.
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.
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.
is working on a reply...