Dynamic items selector from multiple content types Sitefinity [Part 1] [closed]

拈花ヽ惹草 提交于 2021-02-04 16:44:29

问题


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.

  1. 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>
  1. 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 { }
}
  1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!