U4-3776 - v7 - MNTP value type changes between int and string

Created by Jeavon Leopold 02 Dec 2013, 15:15:05 Updated by Stephan 30 Jan 2014, 14:11:55

Relates to: U4-3651

Relates to: U4-4160

When using the MNTP picker in v7 with "Pick multiple items" set, if only a single item is selected the value is returned of type int, if multiple items are picked the value returned is of type string. This is a problem when using dynamic but not so much with typed razor view. e.g. {code:c#} var bannerList = CurrentPage.banner.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); This works fine when there are two items, but if there is one, it will not work.
The workaround is to just add a ToString() {code:c#} var bannerList = CurrentPage.banner.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); Maybe there should be a MNTP property editor value converter which will always return a string...?


Shannon Deminick 02 Dec 2013, 22:03:32

It should just always be string otherwise it's confusing. Also the 'pick multiple items' option is confusing and IMO shouldn't exist but that is just my opinion, have commented about it here: U4-3651

Jeavon Leopold 02 Dec 2013, 22:13:14

Agreed, it should always return a string otherwise it's confusing

Shannon Deminick 02 Dec 2013, 22:22:29

This is just a problem with dynamic, not MNTP. It's to do with retaining legacy logic from the old macro scripts. It's in a method called "ConvertUsingDarkMagic" :P it just attempts to guess the type based on the value - not ideal in this circumstance.

We can create a value converter for MNTP to just return string - would be nicer to make it return an array but that would be a breaking change. People can override this string value converter though...

Jeavon Leopold 02 Dec 2013, 22:46:36

Would be even nicer to return a collection of IPublishedContent but that would definitely be a breaking change! Meanwhile a string converter would be perfect, good job you created a default converter attribute ;-)

Jeavon Leopold 02 Dec 2013, 22:48:27

P.s. Probably irrelevant, but how did it work in v6 as this issue didn't exist with MNTP and dynamic there...?

Shannon Deminick 02 Dec 2013, 22:51:11

perhaps you were storing as xml or weren't selecting a max of 1 node? There's been some changes to published content from stephen but i am pretty sure the auto-converting thing was based on legacy code to maintain compatibility.

Jeavon Leopold 03 Dec 2013, 19:06:33

Just double checked and MNTP does not ever return a int in v6 using CurrentPage even with a single node id being returned...

Shannon Deminick 04 Dec 2013, 04:38:22

Strange, maybe Stephen would know why. I'll create a string MNTP prop ed converter to fix this in any case.

Priority: Normal

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.0.0

Due in version: 7.0.1


Story Points: