Copied to clipboard

Flag this post as spam?

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


  • MuirisOG 382 posts 1284 karma points
    Apr 02, 2019 @ 10:12
    MuirisOG
    0

    PreValues

    We had a PartialViewMacroPage where we checked values in an Umbraco.CheckboxList as follows, which no longer works in version 8.

    @if (Model.Content.Value<string>
        ("myCategoryList")
        .Split(',')
        .Contains("No Search"))
    {
        <meta name="robots" content="noindex, nofollow, noarchive, nosnippet" />
    }
    

    At the moment, the only thing I can find that might help is to assign the value to a variable and then check it using this code:

    var myValue = @Model.Content.GetProperty("myCategoryList").GetSourceValue()
    

    Has anyone any experience of PreValues in Umbraco 8?

    Thanks

    Muiris

  • Gary Taylor 3 posts 73 karma points
    Apr 02, 2019 @ 11:58
    Gary Taylor
    0

    Try the following thread.

  • MuirisOG 382 posts 1284 karma points
    Apr 02, 2019 @ 12:16
    MuirisOG
    0

    Many thanks Gary, but I'm not trying to list the prevalues from the data type itself.

    Muiris

  • Gary Taylor 3 posts 73 karma points
    Apr 09, 2019 @ 07:46
    Gary Taylor
    0

    Hi,

    the PreValues are returned as an enumeration in the model.

    I used the below to create a dropdown list of selected Category's

    <select>@foreach(var item in Model.Category){<option>@item.ToString()</option>}</select>
    
  • Jonathan Distenfeld 105 posts 618 karma points
    Apr 09, 2019 @ 08:26
    Jonathan Distenfeld
    0

    Hi everyone,

    I think the problem you are facing is the Model.Content part. In Umbraco 8, you access properties like this:

    // strongly typed
    Model.MyCategoryList
    
    // dynamic
    Model.Value<string>("myCategoryList")
    

    So the "Content" property does no longer exist.

    -Jonathan

Please Sign in or register to post replies

Write your reply to:

Draft