Restricting MediaContentSelectorView to a single library?

Posted by Community Admin on 04-Aug-2018 18:35

Restricting MediaContentSelectorView to a single library?

All Replies

Posted by Community Admin on 14-Dec-2011 00:00

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>

I looked at the API, and nothing stuck out at me. I'd like to be able to pass it a Library ID or name or something along those lines. Possibly changing the Service URL with a paramater that has a library to use? I can't find any good documentation on this control though.. just the API which doesn't really help too much.

Posted by Community Admin on 14-Dec-2011 00:00

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?

Posted by Community Admin on 19-Dec-2011 00:00

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>

Greetings,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 12-May-2012 00:00

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...

1. You can restrict images by album by specifying the parent id like so:

01.<sitefinity:MediaContentSelectorView
02.    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>

2. You can also access the ItemsList and modify the ConstantFilter in your code like so:

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";

Hope this information proves useful to others.

Cheers,
Josh

Posted by Community Admin on 12-May-2012 00:00

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...

1. You can restrict images by album by specifying the parent id like so:

01.<sitefinity:MediaContentSelectorView
02.    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>

2. You can also access the ItemsList and modify the ConstantFilter in your code like so:

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";

Hope this information proves useful to others.

Apologies for the duplicate post, the first submission resulted in a 500 server error and the second went through, yet both show up. Fun times.

Cheers,
Josh

This thread is closed