Restricting MediaContentSelectorView to a single library?
When creating a custom control designer, is it possible to restrict the MediaContentSelectorView to a single library?
<sf:MediaContentSelectorView CssClass="sfContentViews" id="imageSelector" runat="server" ContentType="Telerik.Sitefinity.Libraries.Model.Image" ParentType="Telerik.Sitefinity.Libraries.Model.Album" LibraryBinderServiceUrl="~/Sitefinity/Services/Content/AlbumService.svc/" MediaContentBinderServiceUrl="~/Sitefinity/Services/Content/ImageService.svc/" MediaContentItemsListDescriptionTemplate="Telerik.Sitefinity.Resources.Templates.Designers.Libraries.Images.ImageItemDescriptionTemplate.htm" DisplayResizingOptionsControl="false" ShowOpenOriginalSizeCheckBox="false"> </sf:MediaContentSelectorView>2 more questions along the same lines:
1. Is it possible to initialize the selector control with an image pre-selected?
2. Where would one go to find how-to's in using controls like this, and other Sitefinity built-in components for creating designers?
Hello Ken Sykora,
What you can do here is change the template of this control and set the filter expression of RadListBoxBinder inside (you will specify which library to filter). You will have to inherit from the MediaContentSelectorView and change the LayoutTemplatePath property to point to the your new template. Then in the template you can set the filter expression. Here's the default template for the view that you can use:
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.ItemLists" TagPrefix="sf" %><%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.Fields" TagPrefix="sfFields" %><%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Modules.Libraries.Web.UI.Designers" TagPrefix="sfViews" %><%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Modules.Libraries.Web.UI.Designers" TagPrefix="sfDesigners" %><%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.ControlDesign" TagPrefix="sf" %> <sf:ResourceLinks ID="resourcesLinks" runat="server"> <sf:ResourceFile JavaScriptLibrary="JQuery" /> <sf:ResourceFile Name="Styles/ListBox.css" /></sf:ResourceLinks><div class="sfSmallLargeColsDim"> <div class="sfClearfix sfColWrapper"> <sf:BinderSearchBox id="searchBox" runat="server" MinCharacters="0" SearchType="Contains" SearchFields="Title" DisableHighlighting="true" BinderBoxLabelText="<%$ Resources:Labels, NarrowByTyping %>" /> <div class="sfLeftCol"> <telerik:RadListBox runat="server" ID="libraryListBox" Skin="Sitefinity" Height="350" Width="125" ></telerik:RadListBox> <sf:RadListBoxBinder id="libraryBinder" runat="server" ServiceUrl="~/Sitefinity/Services/Content/ContentService.svc/" TargetId="libraryListBox" BindOnLoad="false" DataKeyNames="Id" DataMembers="Id, Title"> <Containers> <sf:BinderContainer ID="BinderContainer1" runat="server" RenderContainer="true"> <span>Title</span> </sf:BinderContainer> </Containers> </sf:RadListBoxBinder> </div> <div class="sfUploadedItemWrp sfRightCol"> <sf:ItemsList ID="mediaContentItemsList" runat="server" ServiceBaseUrl="~/Sitefinity/Services/Content/ContentService.svc/" BindOnLoad="false" AllowMultipleSelection="false" DataKeyNames="Id" ConstantFilter="Visible == true AND Status == Live" PageSize="20"> <Items> <sf:ItemDescription Name="ItemDescription1"></sf:ItemDescription> </Items> </sf:ItemsList> </div> </div> <sfDesigners:ResizingOptionsControl id="resizingOptionsControl" runat="server" /></div>I realize this is an old post, but I figured I'd reply with a couple options when using the MediaContentSelectorView that may help others...
01.<sitefinity:MediaContentSelectorView02. id="Selector"03. runat="server"04. ContentType="Telerik.Sitefinity.Libraries.Model.Image"05. ParentType="Telerik.Sitefinity.Libraries.Model.Album"06. LibraryBinderServiceUrl="~/Sitefinity/Services/Content/AlbumService.svc/"07. MediaContentBinderServiceUrl="~/Sitefinity/Services/Content/ImageService.svc/parent/7DE2E6E1-F29B-445C-AA77-2A7A1DD3FF34/"08. MediaContentItemsListDescriptionTemplate="Telerik.Sitefinity.Resources.Templates.Designers.Libraries.Images.ImageItemDescriptionTemplate.htm"09. DisplayResizingOptionsControl="false"10. ShowOpenOriginalSizeCheckBox="false">11.</sitefinity:MediaContentSelectorView>1.var imageSelectorContainer = this.Selector.Controls.OfType<GenericContainer>().First();2.var itemsList = imageSelectorContainer.GetControl<ItemsList>("mediaContentItemsList", true);3.itemsList.ConstantFilter = "Visible == true AND Status == Live";I realize this is an old post, but I figured I'd reply with a couple options when using the MediaContentSelectorView that may help others...
01.<sitefinity:MediaContentSelectorView02. id="Selector"03. runat="server"04. ContentType="Telerik.Sitefinity.Libraries.Model.Image"05. ParentType="Telerik.Sitefinity.Libraries.Model.Album"06. LibraryBinderServiceUrl="~/Sitefinity/Services/Content/AlbumService.svc/"07. MediaContentBinderServiceUrl="~/Sitefinity/Services/Content/ImageService.svc/parent/7DE2E6E1-F29B-445C-AA77-2A7A1DD3FF34/"08. MediaContentItemsListDescriptionTemplate="Telerik.Sitefinity.Resources.Templates.Designers.Libraries.Images.ImageItemDescriptionTemplate.htm"09. DisplayResizingOptionsControl="false"10. ShowOpenOriginalSizeCheckBox="false">11.</sitefinity:MediaContentSelectorView>1.var imageSelectorContainer = this.Selector.Controls.OfType<GenericContainer>().First();2.var itemsList = imageSelectorContainer.GetControl<ItemsList>("mediaContentItemsList", true);3.itemsList.ConstantFilter = "Visible == true AND Status == Live";