App


Data List-Details

Tutorial HomeList-Details
The samples can differ based on your Razor base class or if you're running an old version.
Selected: Typed (2sxc 16+) Switch to Dynamic (Razor14 or below)

Look at the Content-Type of something

In some advanced cases you want to find out information about a specific content-type.

⬇️ Result | Source ➡️

  1. Type Name: "Persons"
  2. Type Internal Name: "e748cf30-7849-46f1-a331-f181ba047cb2"
  3. Type of the Awards field: "Entity"
  4. Values in the Sex field (String) dropdown
    • Unknown = ''
    • Male = 'm'
    • Female = 'f'
    • Non-binary = 'nb'
@inherits Custom.Hybrid.RazorTyped
@using ToSic.Eav.Data;

@{
  var type = MyItem.Type;
  var attributes = type.Attributes as IEnumerable<IContentTypeAttribute>;
  var sexAttr = attributes.First(t => t.Name == "Sex");
  // Check the metadata for the DropdownValues in the type @string-dropdown
  var sexDropdown = sexAttr.Metadata.GetBestValue<string>("DropdownValues", "@string-dropdown");
}
<ol>
  <li>Type Name: "@type.Name"</li>
  <li>Type Internal Name: "@type.StaticName"</li>
  <li>Type of the Awards field: "@attributes.First(t => t.Name == "Awards").Type"</li>
  <li>
    Values in the <code>Sex</code> field (@sexAttr.Type) dropdown
    <ul>
      @foreach (var s in sexDropdown.Split(new [] { '\r', '\n' }))
      {
        var parts = s.Split(':');
        <li>@parts[0] = '@(parts.Length > 0 ? parts[1] : "")'</li>
      }
    </ul>
  </li>
</ol>

View Configuration

This is how this view would be configured for this sample.

  • Content/Item ContentType: Persons
  • Content/Item Data:
    1. Douglas (ID: 46284)

⬇️ Result | Source ➡️

  • First Name (FirstName, String = typeId 6)
  • Last Name (LastName, String = typeId 6)
  • Birthday (Birthday, DateTime = typeId 2)
  • Mugshot (Mugshot, Hyperlink = typeId 4)
  • Awards (Awards, Entity = typeId 3)
  • Sex (Sex, String = typeId 6)
  • FavoriteNumber (FavoriteNumber, Number = typeId 5)
  • IsAlive (IsAlive, Boolean = typeId 1)
  • Haters (Haters, Entity = typeId 3)
  • Biography (Biography, String = typeId 6)
@inherits Custom.Hybrid.RazorTyped

@{
  var type = MyItem.Type;
}
<ul>
    @foreach (var attr in type.Attributes) {
    <li>
      @* This will get the label from the metadata entity *@
      @(attr.Metadata.GetBestValue<string>("Name", "@All"))
      (@attr.Name, <code>@attr.Type</code> = typeId @((int)attr.Type))
    </li>
  }
</ul>

View Configuration

This is how this view would be configured for this sample.

  • Content/Item ContentType: Persons
  • Content/Item Data:
    1. Douglas (ID: 46284)