OpenWGA 7.9 - TMLScript reference

TMLContext "this"
Method :

fileurl([[dbkey,] containername,] filename)

On object TMLContext "this"
Usage Creates a URL pointing to a file attachment on a content document or file container
Description This method is able to point to file attachments in both content documents or file containers. The containername therefor is either the key of a content document or the name of a file container.

If the dbkey parameter is omitted OpenWGA must determine if the file container to use is available in the current design database (which might be a different one than the current context db, see designdb). If it finds a container of the given name it creates an URL to that. Otherwise it creates a URL that points to a file container or content document in the database of the current content context (the URL syntax is the same for both).

As OpenWGA is able to serve single files that are contained inside an attached ZIP archive you may also use attribute filename not only to address the ZIP file, but also some file that is contained in it. Just continue the file name with a slash and specify the path of the contained file after that, eventually using further slashes to provide deeper path information.

dbkey (String, optional):

Database key of the database whose file is to be served.

containername (String, optional):

Name of a file container or key of a content document. Specify null or omit to use the current context content document.

filename (String):
Name of the file attachment on file container or content document. If the file is a ZIP archive you can address files inside it by specifying the path in the ZIP file after the name, divided by slashes.
Return value URL pointing to a file attachment (String)
Allowed in script types
  • WebTML pages and normal WebTML actions
Examples A simple file URL to a file attachment "dax.gif" in a file container "images":

return fileurl("images", "dax.gif");

Specifying a special database "globaldesign":

return fileurl("globaldesign", "images", "dax.gif");

Specifying a file at path "16x16/folder.png" inside a ZIP file attachment "". OpenWGA will serve the single file inside the archive when the URL is called:

return fileurl("archives", "");

A file url pointing to a file attachment "picture.gif" on content document with name "home". We retrieve the conten key of the "home" document via context change:

return fileurl(context("name:home").KEY, "picture.gif");