• Jonathan Read (Progress Software)

    Hey @Prachika Pal (Customer)​ when requesting information or help on the forums it is really useful to try and explain your trouble in detail, screenshots, steps to reproduce, etc. That being said I am going to make assumptions about what you are asking and try to answer it.

     

    With the ASP.NET Core renderer and using the ContentList widget the field mappings from from the ~/Views/Shared/Components/SitefinityContentList/ViewMetaData.json file

    imageWith the default installation of Sitefinity this file is loaded from the DLL for Sitefinity widgets. If you would like to modify or add field mappings for custom templates you can create the folder structure ~/Views/Shared/Components/SitefinityContentList and add your templates and the ViewMetaData.json

     

    https://www.progress.com/documentation/sitefinity-cms/create-custom-views-for-the-content-list-widget#field-mappings

     

    I recommend copying the default from: https://github.com/Sitefinity/sitefinity-aspnetcore-mvc-widgets/tree/master/Progress.Sitefinity.AspNetCore.Widgets/Views/Shared/Components/SitefinityContentList

     

    You will also find all the default templates there which you could place in your project and override if you wish.

  • Prachika Pal (Customer)

    I have added the mobileImage field in ViewMetaData.json file. I want to access the mobileImage in a contentList custom widget but not able to do so.

    Using the model - @model Progress.Sitefinity.AspNetCore.Widgets.Models.ContentList.ContentListViewModel

    • Jonathan Read (Progress Software)

      With a content lising widget you can use the GetFieldValue<Type>(SdkItem, "FieldName") to retrieve and mapped field.

      1. @foreach (var item in Model.Items){
      2. var images = Model.GetFieldValue<List<ImageDto>>(item, "{{FieldName}}");
      3. }

       

  • Prachika Pal (Customer)

    This is working in staging environment but not in auth.

     

    I have done the field mapping like below in viewsMetaData.json:

     

     "CompositeCard": [

      {

       "fieldTitle": "Image",

       "fieldType": "RelatedImages"

      },

      {

       "fieldTitle": "MobileImage",

       "fieldType": "RelatedImages"

      }

     ]

     

    Then trying to fetch the "mobile image" field inside the .cshtml file like below:

     

    @{

      var items = Model.Items.Where(itm => !string.IsNullOrWhiteSpace(Model.GetFieldValue<string>(itm, "Title")));

    }

    @if (items.Count() > 0)

    {

     @foreach (var (item, index) in items.Take(5).Select((value, i) => (value, i + 1)))

     {

       var img = Model.GetFieldValue<IEnumerable<ImageDto>>(item, "Image").FirstOrDefault();

       var mobileImg = Model.GetFieldValue<IEnumerable<ImageDto>>(item, "MobileImage").FirstOrDefault();

    }

    }

     

    "mobileImg" data is coming in staging environment but not in auth environment.

     

  • Jonathan Read (Progress Software)

    Is there CDN or other caching in place? Can you clear it? Are you sure the items have a "MobileImage"? Did you map the fields correctly?