November Happy Hour will be moved to Thursday December 5th.

Use the File Manger in a plugin

Vote:
 
In a plugin we use I would like to have the same functionallity as the property type "URL to Image". Is it possible to use that in a plugin you have written yourself? Here's what I would like to do: In the plugin I have a textbox were I would like to write in the virtual path to a file. The best thing I could think of is to use the exakt same functionallity as the "URL to Image" property-type. That is, a textbox with at button that opens the file manager. One can then select the file in the file manager and click "OK" to close it and set the virtual path of the file in the textbox. Best regards, Jonas
#13361
Feb 18, 2008 16:39
Vote:
 
Assuming that you're running version 4.x here is sample code to get you started: Include the following javascript files <script type='text/javascript' src="<%=EPiServer.Global.EPConfig.RootDir%>util/javascript/system.js"> <script type='text/javascript' src="<%=EPiServer.Global.EPConfig.RootDir%>util/javascript/common.js"> Include a button that calls a javascript function to loads the FileManager <script type="text/javascript"> function SelectImageLink() { var url = '/<%= EPiServer.Global.EPConfig.EditDir %>FileManagerBrowser.aspx'; var returnvalue; var linkAttributes = new Object(); returnValue = OpenDialog(url, linkAttributes, 445, 412); if (returnValue != undefined && returnValue != 0) { // do your stuff here } } /Mari
#19081
Feb 19, 2008 21:27
Vote:
 

Hi,

I wish to do pretty much the same thing.  I would like to use the exact same functionality as the 'URL to Image' property but am using EPiServer CMS Version 5 SP1.

 Please could you tell me how to do this?

Thanks

 Carl

#19573
Apr 18, 2008 10:23
Vote:
 

Include the following javascript files

<script type='text/javascript' src="<%= EPiServer.UriSupport.ResolveUrlFromUtilBySettings("javascript/episerverscriptmanager.js") %>"></script>

<script type='text/javascript' src="<%= EPiServer.UriSupport.ResolveUrlFromUIBySettings("javascript/system.js") %>" ></script>

<script type='text/javascript' src="<%= EPiServer.UriSupport.ResolveUrlFromUIBySettings("javascript/system.aspx") %>" ></script>

Include a button that calls a javascript function to loads the FileManager

// Pass the page or parent page id to the popup. Will be used in page browser dialog var pageId = ''; var parentPageId = '';   // The file manager needs the folder id in order to show or create the "Page Files" directory.  var folderId = '';  function SelectImageLink() {  var url = '?id=' + pageId + '&parent=' + parentPageId + '&folderid=' + folderId; url += '&selectedfile=' + selectedfile;  var linkAttributes = new Object();  var dialogArguments = linkAttributes; var features = {width: 600, height: 412}; var callbackArguments = new Object();  /* opens the filemanagerbrowser dialog */  EPi.CreateDialog( url, OnFileDialogClosed, callbackArguments, dialogArguments, features);  }

Specify the javascript fuction that should run when an image is selected

/* function called after file browser dialog has returned and closed*/

function OnFileDialogClosed(returnValue, callbackArguments) { if (returnValue != undefined && returnValue != 0) {  //do your stuff here } }
#19579
Edited, Apr 18, 2008 13:53
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.