Without digging into the Umbraco core, I'm not 100% sure what the Razor engine does with MNTP values - but I do know that there is a specific check for MNTP and some manipulation happens.
An alternative could be to look at the Razor DataType Models project? - it's not a "proper" package yet, although if you pull down the source there is an MSBuild script in the "_build" directory that will generate the package for you.
This is a known issue, see my comment to this issue (bottom of the page). It's been fixed for 4.7.1.1.
Instead of @Model.GetProperty("name").Value, try using @Model.GetPropertyValue("name") everywhere (new in 4.7.1), it's a bit nicer and I believe it does null checking for you, so if the property is empty, you get an empty string back.
Thanks Lee and Sebastiaan. I've got the dev to swich over to using .GetPropertyValue :)
The RazorDataTypes thing sounds good, but we dont use them that much - and we have worker methods already, which take (for eg) a CSV list of node ids, and return a lit of products (from our product database), doing all the load-a-node-and-lookup-a-field nonsense behind the scenes.
Cheers guys. Pity I can't mark both as "great answers" (or can I?)
Interesting MNTP / CSV problem - 2 items doesn't work [with solution]
First up, I found a solution. Do this:
@Model.GetProperty("name").Value
Not:
@Model.name
The problem:
I have an MNTP which picks to a CSV. I can pick a few items, and it usually works. I'm pulling it out with @Model.propertyName
1 item works fine. 1234 is the result, and also in the umbraco.config
2 items DOES NOT work fine. 12345678 is the result, but the config has 1234,5678 in it.
3 or more items DOES WORK. 1234,5678,9012 etc etc.
The solution above fixes it. Any ideas why?
I'm using 4.7.1 with uC 3, but it was happening with uC 2, and I doubt uC is the problem.
Hi Nic,
Without digging into the Umbraco core, I'm not 100% sure what the Razor engine does with MNTP values - but I do know that there is a specific check for MNTP and some manipulation happens.
An alternative could be to look at the Razor DataType Models project? - it's not a "proper" package yet, although if you pull down the source there is an MSBuild script in the "_build" directory that will generate the package for you.
Cheers, Lee.
This is a known issue, see my comment to this issue (bottom of the page). It's been fixed for 4.7.1.1.
Instead of @Model.GetProperty("name").Value, try using @Model.GetPropertyValue("name") everywhere (new in 4.7.1), it's a bit nicer and I believe it does null checking for you, so if the property is empty, you get an empty string back.
Thanks Lee and Sebastiaan. I've got the dev to swich over to using .GetPropertyValue :)
The RazorDataTypes thing sounds good, but we dont use them that much - and we have worker methods already, which take (for eg) a CSV list of node ids, and return a lit of products (from our product database), doing all the load-a-node-and-lookup-a-field nonsense behind the scenes.
Cheers guys. Pity I can't mark both as "great answers" (or can I?)
You can "High five" Lee's question! :-)
I did :) and yours. Except, it's not saving them :(
is working on a reply...