The XHTML WYSIWYG Editor For Desktop & Web Applications

Creating a dynamic image library

Change library name

The image library is accessed through a server-side script called imagelibrary.aspx (.asp or .php). XStandard points to the location of this script through the ImageLibraryURL <param> tag like this:

  1. <param name="ImageLibraryURL" value="http://soap.xstandard.com/imagelibrary.aspx" />

Inside the imagelibrary.aspx script, there is a variable that points to the imagelibrary.config file. The name of the library displayed by the editor is stored inside the imagelibrary.config file. Please note, after modifying imagelibrary.aspx or imagelibrary.config you will need to re-start the editor, because it caches general information about the image library.

Dynamically setting the library folder

Inside imagelibrary.aspx (.asp or .php), there is a variable that specifies the path to the folder on the hard drive where images are stored. In order to create a dynamic image library, the value of this variable needs to change to match the document being edited in the CMS. To do this, XStandard has special <param> tags that pass data from the editor to Web services such as imagelibrary.aspx using HTTP headers. One of these <param> tags is called DocumentID and you can set its value to the ID of the document being edited. For example:

  1. <param name="DocumentID" value="A7490129-F72E-4843-BCFE-784AC9BF8F97" />

From imagelibrary.aspx, the document ID can be read from the HTTP header called X-Document-ID. Then this value can be used to adjust the path to the folder containing the images for the document being edited. For example (in C#):

  1. string libraryFolder = Server.MapPath(".");
  2. if (Request.ServerVariables["HTTP_X_DOCUMENT_ID"] != null)
  3. {
  4. if (Request.ServerVariables["HTTP_X_DOCUMENT_ID"] != String.Empty)
  5. {
  6. libraryFolder = Server.MapPath("/resources/" + Request.ServerVariables["HTTP_X_DOCUMENT_ID"]);
  7. }
  8. }