Copied to clipboard

Flag this post as spam?

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


  • Craig100 1136 posts 2523 karma points c-trib
    Apr 19, 2018 @ 18:35
    Craig100
    0

    Missing something basic

    Umb 7.5.11, legacy site, ModelsBuilder Off.

    I can't work out what's missing if, in a partial with all these usings (which are actually being used):-

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @using System.Collections.Generic;
    @using System.Linq;
    @using System.Web.Security;
    @using Umbraco.Core.Models;
    @using Newtonsoft.Json.Linq;
    

    I'm having to use JArray to get RelatedLinks as RelatedLinks isn't in Umbraco.Web.Models

    And the following won't work to get data out of a Dropdown List Multiple (this is example code from the docs)

    @{
      if (Model.Content.HasValue("superHeros")){                                                     
           <ul>                                                        
          @foreach(var item in Model.Content.GetPropertyValue<string>("superHeros").Split(',')) { 
            <li>@item</li>
          }
        </ul>                                                                                       
      }
    }
    

    If I ask if(Model.Content.HasProperty("superHeros")) it succeeds. If I ask if(Model.Content.HasValue("superHeros")) it quietly fails as if it has no value, which I know it does!

    Any advice would be appreciated.

    -Craig

  • Kevin Jump 2341 posts 14868 karma points MVP 8x c-trib
    Apr 19, 2018 @ 20:07
    Kevin Jump
    0

    Hi

    I know its probably not this - but just to confirm your usings have Umbraco.Core.Models, and not Umbraco.Web.Models too. - is that right ?

    Kevin

  • Craig100 1136 posts 2523 karma points c-trib
    Apr 19, 2018 @ 20:20
    Craig100
    0

    As of the latest build, it's not "using" either. Umbraco.Core.Models (says it's already in use) or Umbraco.Web.Models (says it's not required).

    If I try to type in var newitem = block.GetPropertyValue<Umbraco.Web.Models.>("myLinks") RelatedLinks isn't offered after Models.It's as if web.config or the dll's are the wrong version maybe. It's a very hacked about site and other devs have a habit of keeping their own web.config files so I can imagine it's something like that. Unless there's a more obvious answer I can't see. Wish I could build the thing again from scratch, but not allowed :(

  • Craig100 1136 posts 2523 karma points c-trib
    Apr 19, 2018 @ 21:10
    Craig100
    0

    The dropdown list multiples are being stored in Nested Content. I just came across this: https://github.com/umco/umbraco-nested-content saying there's an issue with them, checkbox lists and radio button lists. Looks like I'm going to have to re-engineer this solution again.

Please Sign in or register to post replies

Write your reply to:

Draft