问题
I had to develop a carousel which should display items from multiple content types, and at the backend customer can select items manually. Sitefinity provides a OOB solution to select items at the backend but for single content type only. In order to fulfill this requirement. I have done changes in OOB js files provided by Sitefinity.
- In your
DesignerView.<viewName>.cshtml
file, paste the following tag in html code:
<sf-list-selector sf-dynamic-items-selector sf-identifier-field="Title"
sf-multiselect="true" sf-sortable="true" sf-master="false"
sf-provider="properties.ProviderName.PropertyValue"
sf-selected-ids="properties.SerializedSelectedItemsIds.PropertyValue"
sf-selected-items="properties.SerializedSelectedItems.PropertyValue"
sf-item-type="'Telerik.Sitefinity.DynamicTypes.Model.Jobs.Job;Telerik.Sitefinity.DynamicTypes.Model.JobProviders.JobProvider;Telerik.Sitefinity.DynamicTypes.Model.Articles.Article'"
sf-carousel="true"
sf-selected-providers="properties.SerializedSelectedItemsProviders.PropertyValue"
sf-selected-itemtypes="properties.SerializedSelectedItemsTypes.PropertyValue"></sf-list-selector>
- You must add a property in your widget's controller that gets and sets that type. Only after that you can access this property using the scope.properties.ProviderName.PropertyValue:
public string SerializedSelectedItemsIds { get; set; }
public string SerializedSelectedItems { get; set; }
public string SerializedSelectedItemsProviders { get; set; }
public string SerializedSelectedItemsTypes { get; set; }
public string ProviderName
{
get {
return "Provider name for jobs" + ";" +
"Provider name for JobProviders" + ";" +
"Provider name for Articles";
}
set { }
}
- Add following folder structure in your project's root: See client component folder structure
- client-components
- fields
- selectors
- common
- dynamic-modules
Part 2 link
来源:https://stackoverflow.com/questions/65809816/dynamic-items-selector-from-multiple-content-types-sitefinity-part-1