We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. Some of these cookies also help improve your user experience on our websites, assist with navigation and your ability to provide feedback, and assist with our promotional and marketing efforts. Please read our
Cookie Policy for a more detailed description and click on the settings button to customize how the site uses cookies for you.
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
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.
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
With a content lising widget you can use the GetFieldValue<Type>(SdkItem, "FieldName") to retrieve and mapped field.
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.
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?