Copied to clipboard

Flag this post as spam?

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


  • Nic Wise 51 posts 85 karma points
    Nov 30, 2011 @ 17:13
    Nic Wise
    0

    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. 

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Nov 30, 2011 @ 17:17
    Lee Kelleher
    1

    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.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Nov 30, 2011 @ 17:24
    Sebastiaan Janssen
    0

    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.

  • Nic Wise 51 posts 85 karma points
    Nov 30, 2011 @ 18:06
    Nic Wise
    0

    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?)

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Nov 30, 2011 @ 18:08
    Sebastiaan Janssen
    0

    You can "High five" Lee's question! :-)

  • Nic Wise 51 posts 85 karma points
    Nov 30, 2011 @ 18:44
    Nic Wise
    0

    I did :) and yours. Except, it's not saving them :(

Please Sign in or register to post replies

Write your reply to:

Draft