Document selector for 4.2

Posted by Community Admin on 03-Aug-2018 20:02

Document selector for 4.2

All Replies

Posted by Community Admin on 24-Aug-2011 00:00

Hi,

How can i create a document selector for my custom module?
I need this feature for module backend so content editors can select a uploaded document or upload a new document.
Document link will be saved to a textbox after selecting the document.

Can you provide a sample code please?

Thanks,
Suranga

Posted by Community Admin on 29-Aug-2011 00:00

Hello Su,

 Please check this article, which shows how to create a Document selector:
http://www.sitefinity.com/devnet/forums/sitefinity-4-x/bugs-issues/looking-similar-imageselector-for-document-list.aspx
If you need any further assistance, feel free to write back.

Kind regards,
Svetoslav Petsov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Posted by Community Admin on 30-Aug-2011 00:00

Hi Svetoslav ,

Thank you for your reply. This code only woks for widgets it seems to me.
How can i create one to use for Custom modules backend? When i add a new item for my module i need to select (or upload) a document related to the module entry.

Thanks,
Su

Posted by Community Admin on 30-Aug-2011 00:00

Hello Su,

 Your request has been answered at the support ticket. The solution provided is for modules that inherit from ContentModuleBase. If your module is inheriting from module base the solution is different.

For the benefit of the community here is the solution we provided:

We don`t have a definition for document selector. Your request can be achieved by creating a custom field for the module and using document selector dialog in this field to upload documents in a library and select documents from existing libraries.
I have attached a project with EditorContentManagerDialog. You can use it for the custom field.
The current mode is to select images

Copy Code
DialogMode="Image" //change it to Document or the other available options


The sample works by displaying a button in the module backend that will open RadWindow(SelectorUserControl.ascx). In the window the document selector will be loaded(ImageSelectorDialog.ascx). It is taking the functionality from(ImageSelectorDialog.cs).
In the scenario where you have module with definitions the approach to add the field is:
1.Create a custom field for the module(short text).
2.(refer to this post for more information oh how to create a customized custom field with your own template)
3. The field will have to display the rad window(SelectorUserControl.ascx) so it will have to be created similar to the sample in the post. The .ascx file will be embedded resource and you will have to create a code file that will call the embedded template with rad window. The code file have to add virtual path to the template

Copy Code
protected override string LayoutTemplateName
        
            get
            
                return ChoiceFieldCustom.layoutTempalte; // this is the name of the class
            
        
 
private const string layoutTempalte = "~/Samples/SitefinityWebApp.Choice.AlbumSelectorField.ascx"; // this is the full path to the file which is under folder Choice and the virtuial path is called  ~/Samples/

After creating this go to settings for the module (I will give example with products module) Products->Controls->ProductsBackend->Views->(select view)->Sections->CustomFieldSection and find the field you created and in field type you should be having Telerik.Sitefinity.Web.UI.Fields.TextField change it to YourProjectName.PathToTheCodeFileOfRadWindowControl.

You have to register the virtual path you assigned in the code file. Go to Administration->Settings->Advanced->VirtualPathSettings->VirtualPaths and create new virtual path
VirtualPath: ~/Samples/*
ResourceLocation: Name of your assembly
ResolverName: EmbeddedResourceResolver
(A virtual path have to be created for the dialog code file as it references embedded .ascx file with the dialog too. This is done if the VP names are different).
4. Modify the .js file to use the namespaces of your project and remember to register the .js file in AssemblyInfo.cs

Copy Code
[assembly: WebResource("SitefinityWebApp.Controls.Resources.Scripts.ImageSelectorDialog.js", "application/x-javascript")]

5. Check all namespaces of all code files. register the virtual paths and restart the application(make a dummy change in web.config) to apply the changes.
6. Copy the Global.asax file from the project I sent. It is used to call the dialog.

Excuse me for the long description. This is the method to add the dialog in a module since it is only available trough opening in a dialog.

Regards,
Svetoslav Petsov
the Telerik team

[View:/cfs-file/__key/communityserver-discussions-components-files/295/296293_5F00_296154_2D00_ImageSelectorUC_2D00_part2.rar:320:240]

[View:/cfs-file/__key/communityserver-discussions-components-files/295/296292_5F00_296153_2D00_ImageSelectorUC_2D00_part1.rar:320:240]

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

This thread is closed