2

DXA 1.6 / MVC

We are getting NULL from a field that should contain a list of Components (itemListElement):

(Note: we are able to see the values of SectionHeading and SubHeading as expected)

[SemanticEntity(Vocab = CoreVocabulary, EntityName = "ImageCardList", Prefix = "s", Public = true)]
public class ImageCardList : EntityModel
{
    [SemanticProperty("s:sectionHeading")]
    public string SectionHeading { get; set; }

    [SemanticProperty("s:subHeading")]
    public string SubHeading { get; set; }

    [SemanticProperty("s:itemListElement")]
    public List<ImageCardItem> ItemListElement { get; set; }
}

ImageCardItem:

[SemanticEntity(EntityName = "ImageCard", Prefix = "s", Vocab = CoreVocabulary, Public = true)]
public class ImageCardItem: EntityModel
{
    [SemanticProperty("s:headline")]
    public string Headline { get; set; }

    [SemanticProperty("s:content")]
    public string Content { get; set; }

    [SemanticProperty("s:media")]
    public MediaItem Media { get; set; }

    [SemanticProperty("s:link")]
    public Link Link { get; set; }
}

All fields in Tridion match up with the SemanticProperties specified above:

1

itemListElement only allows an "ImageCard" schema to be used:

2

There is no controller, just a view:

@using Sdl.Web.Mvc.Html;
@model ImageCardList

@if (Model.ItemListElement != null)
{
    // HTML HERE
}

Finding it difficult to find any information on this - I imagine it is possible as we have previously done this using RazorTemplating.

Any help would be most appreciated - happy to give more information!

EDIT: Logs below:

2017-06-07 08:56:14,253 [11] TRACE -     HtmlHelperExtensions.DxaEntities(System.Web.Mvc.HtmlHelper`1[Sdl.Web.Common.Models.RegionModel], 0) entry.
2017-06-07 08:56:14,253 [11] TRACE -       HtmlHelperExtensions.DxaEntity(System.Web.Mvc.HtmlHelper`1[Sdl.Web.Common.Models.RegionModel], ImageCardList: 333, 12) : BLAH:Entity:ImageCardCarousel entry.
2017-06-07 08:56:14,254 [11] TRACE -       HtmlHelperExtensions.DxaEntity() exit. Duration: 0 ms.
2017-06-07 08:56:14,254 [11] TRACE -     HtmlHelperExtensions.DxaEntities() exit. Duration: 1 ms.
  • Can you edit your question and supply some details about the Schema ImageCardList, specifically the XML names of its fields – Bart Koopman Jun 6 '17 at 11:39
  • Added extra details on the schema "ImageCardList" – Bryn Curran Jun 6 '17 at 11:45
  • Which version of DXA are you using? Note that DXA 1.7 has improved diagnostic logging (set log level to DEBUG) for model mapping issues. – Rick Pannekoek Jun 6 '17 at 19:11
  • We are using DXA 1.6 - nothing in the logs suggest there is anything wrong. – Bryn Curran Jun 7 '17 at 8:01
  • 1
    Is it a new field you recently added? Did you republish the system "Settings" page? – Hao Peng Jun 7 '17 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.