Article information
Article relates to
Sitefinity 3.2 or later
Created by
Pepi & Rebecca
This article describes how to add a Library selector similar to the Thumbnail selector in News to all modules based on Generic Content: The attached LibrarySelector user control gives you the ability to choose and associate files from the Images and Documents module, as well as from the file system. The LibrarySelector control has a DisplayMode property that gets or sets the selected library mode. By default the property is set to Auto and the control works in as if in Image mode, i.e. the Insert an image dialog opens. In the example below DisplayMode is set to Document, which means that the Insert a document dialog will open when the user clicks Select. The user has the option to upload a file to a document library or the file system and to select files already uploaded in document libraries or physical folders. This control can be used both in Sitefinity administration (as it implements the ITextControl interface) and in the public part. I. To enable it in the News module administration, follow these steps: 1. In the ~/UserControls folder, create a subfolder called Libraries and place the two files from the attached archive: LibrarySelector.ascx and LibrarySelector.ascx.cs. 2. Open the application web.config and in section <metaFields>, add this key:
3. Register the control in the ControlPanelEdit.ascx and ControlPanelInsert.ascx templates located in ~/Sitefinity/Admin/ControlTemplates/News folder:
4. Declare the control inside the ItemTemplate of the ContentMetaFields control and set its ID to the meta key:
II. To display the LibrarySelector in the Add Controls toolbox and use it as a public control, you need to add the following declaration in the <toolboxControls> section of the application web.config: