Copied to clipboard

Flag this post as spam?

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


  • Anders Schmidt 76 posts 207 karma points
    Apr 11, 2014 @ 13:54
    Anders Schmidt
    0

    Getting preValues form custom data type (DropDownMultiple) with razor

    I am trying to list all values form a DropDownMultiple with razor. But without any luck. Using Umbraco7.1

    I am quit confused regarding the textstring alias / ID

    Can anyone show me the snippet?

    Thanks.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Apr 11, 2014 @ 14:07
    Jeavon Leopold
    0

    Hi Anders,

    I have this documentation in process (these are the snippets from it) :-)

    Here's what you need:

    Dynamic

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

    Typed

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

    Jeavon

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Apr 11, 2014 @ 14:10
    Jeavon Leopold
    0

    Ah wait, do you mean Dropdown List, Publish Keys?

  • Anders Schmidt 76 posts 207 karma points
    Apr 11, 2014 @ 14:16
    Anders Schmidt
    0

    Hi Jeavon

    And thanks for quick response :-)

    Sorry if Im not making myself clear. I would like tol list: All values from a data type. ALL PREVALUES

    I am not aware of the therm Publish Keys

    Thanks

    /Anders 

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Apr 11, 2014 @ 14:22
    Jeavon Leopold
    102

    Ok, how about this:

    @{
        var dts = ApplicationContext.Current.Services.DataTypeService;
        var prevalues = dts.GetPreValuesByDataTypeId(1125);
        foreach (var prevalue in prevalues)
        {
            <p>@prevalue</p>
        }
    }
    
  • Anders Schmidt 76 posts 207 karma points
    Apr 11, 2014 @ 14:30
    Anders Schmidt
    0

    Hi Jeavon

    YES YES. THANKS

    But how will i be able of finding/see the ID besides going into table?

    THANKS

     

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Apr 11, 2014 @ 15:02
    Jeavon Leopold
    1

    When you edit the data type you can see it's id in the address bar :-)

Please Sign in or register to post replies

Write your reply to:

Draft