Content Picker GetPropertyValue<int> is broken (v.6.2.1) - umbracoRedirect doesn't work
Hi guys,
just upgraded my Umbraco 6.1.3 install to 6.2.1. Using [...] Converters package 1.0.4-beta.
When we have ContentPicker value converter to IPublishedContent type object, other default converters doesn't seem to work, especially node.GetPropertyValue<int>("contentPickerField"). It always returns 0. It is because value converter returns IPublishedContent object, which can't be converted to requested <int> value.
For now I've seen that this breaks two things:
umbracoRedirect - somewhere in the core probably GetPropertyValue<int> is used, always getting 0 and thus redirects doesn't work
umbracoPageNotFound - same here, this is implemented in ucomponents (or will be, taken from https://gist.github.com/leekelleher/9367600 ). Not a big issue, but it shows that there might be other places that get affected
As a workaround, I've added some property alias checks in ContentPickerPropertyEditorValueConverter.cs:
public bool IsConverterFor(Guid propertyEditorId, string docTypeAlias, string propertyTypeAlias)
That's a really good point, I already handle the same issue for "umbracoInternalRedirectId" in both the v1.1 (Umbraco6.2) and the v2(Umbraco v7) branches so I'm going to add these two additional properties to not convert.
I just this morning began the process of moving from BitBucket to GitHub and have completed the v2 move, I'm now working on moving v1.1, so it will be there shortly.
I'll let you know when I release the new versions, there will also be Nuget packages as alternatives to the Umbraco packages.
I have been looking into this and unfortunately I've not been able to do this with Umbraco v6 but thankfully it is possible with v7 due the changes in the way the value converters work.
I think for a v6 site you may find that using a textfield editor for these special properties is a viable workaround, if not you could either do a custom build of the converters without the content converter or create a duplicate of the content picker property editor in your solution just for these properties.
You can find the source code for v1 (Umbraco v6) now on GitHub here
I've just released v1.1.0 which does not convert umbracoRedirect or umbracoInternalRedirectId but you will need to adjusts Lee's code for umbracoPageNotFound as this is not a Umbraco standard.
I can confirm that umbracoRedirect works on v6.2.1 with package v1.1.0 .
But for other properties ("umbracoPageNotFound", etc.), GetPropertyValue<int> will always return 0. IPublishedContent return type should be used instead.
Content Picker GetPropertyValue<int> is broken (v.6.2.1) - umbracoRedirect doesn't work
Hi guys,
just upgraded my Umbraco 6.1.3 install to 6.2.1. Using [...] Converters package 1.0.4-beta.
When we have ContentPicker value converter to IPublishedContent type object, other default converters doesn't seem to work, especially node.GetPropertyValue<int>("contentPickerField"). It always returns 0. It is because value converter returns IPublishedContent object, which can't be converted to requested <int> value.
For now I've seen that this breaks two things:
I personally do not use bitbucket (waiting for github), so it would be good if somoeone could create a commit for this.
Any ideas how it can be solved without hardcoding property aliases?
Probably the nicest solution would be to somehow write separate methods for separate types, ex:
But I don't think something like this is possible now. Maybe I should create thread on main Umbraco forum for this.
Hi Pavel,
That's a really good point, I already handle the same issue for "umbracoInternalRedirectId" in both the v1.1 (Umbraco6.2) and the v2(Umbraco v7) branches so I'm going to add these two additional properties to not convert.
I just this morning began the process of moving from BitBucket to GitHub and have completed the v2 move, I'm now working on moving v1.1, so it will be there shortly.
I'll let you know when I release the new versions, there will also be Nuget packages as alternatives to the Umbraco packages.
Cheers,
Jeavon
Hi Pavel,
I have been looking into this and unfortunately I've not been able to do this with Umbraco v6 but thankfully it is possible with v7 due the changes in the way the value converters work.
I think for a v6 site you may find that using a textfield editor for these special properties is a viable workaround, if not you could either do a custom build of the converters without the content converter or create a duplicate of the content picker property editor in your solution just for these properties.
You can find the source code for v1 (Umbraco v6) now on GitHub here
Thanks,
Jeavon
Doh, maybe I'm wrong, just after I posted that it now seems to be work.....
I've just released v1.1.0 which does not convert umbracoRedirect or umbracoInternalRedirectId but you will need to adjusts Lee's code for umbracoPageNotFound as this is not a Umbraco standard.
Could you please let me know if it works?
e.g.
Hi Jeavon,
thanks for quick reply.
Good to hear that this will work in v7.
As for v6 I will edit Lee's code to use IPublishedContent instead of int, it will work (tried that already).
Cheers
v1.1.0 should work and is for v6.2
I can confirm that umbracoRedirect works on v6.2.1 with package v1.1.0 .
But for other properties ("umbracoPageNotFound", etc.), GetPropertyValue<int> will always return 0. IPublishedContent return type should be used instead.
is working on a reply...