FILES

A content object of type FILES uses the File Abstraction Layer (FAL) and is used to display information about files.

Properties

files

files
Data type

string / stdWrap

Comma-separated list of sys_file UIDs, which are loaded into the FILES object.

Example:

page.10 = FILES
page.10.files = 12,15,16

references

references
Data type

string / stdWrap or array

Provides a way to load files from a file field (of type IRRE with sys_file_reference as child table). You can either provide a UID or a comma-separated list of UIDs from the database table sys_file_reference or you have to specify a table, uid and field name in the according sub-properties of "references". See further documentation of these sub-properties in the table below.

Examples:

references = 27,28

This will get the items from the database table sys_file_reference with the UIDs 27 and 28.

references {
  table = tt_content
  uid = 256
  fieldName = image
}

This will fetch all relations to the image field of the tt_content record "256".

references {
  table = pages
  uid.data = page:uid
  fieldName = media
}

This will fetch all items related to the page.media field.

collections

collections
Data type

string / stdWrap

Comma-separated list of sys_file_collection UIDs, which are loaded into the FILES object.

folders

folders
Data type

string / stdWrap

Comma-separated list of combined folder identifiers which are loaded into the FILES object.

A combined folder identifier looks like this: [storageUid]:[folderIdentifier].

The first part is the UID of the storage and the second part the identifier of the folder. The identifier of the folder is often equivalent to the relative path of the folder.

The property folders has the option recursive to get files recursively.

Example:

page.10 = FILES
page.10.folders = 2:mypics/,4:myimages/

Example for option recursive:

filecollection = FILES
filecollection {
   folders = 1:images/
   folders.recursive = 1

   renderObj = IMAGE
   renderObj {
      file.import.data = file:current:uid
   }
}

sorting

sorting
Data type

string / stdWrap

Name of the field, which should be used to sort the files.

sorting.direction
Data type

string / stdWrap

Default

asc

The direction, in which the files should be sorted. Possible values are "asc" for ascending and "desc" for descending.

begin

begin
Data type

integer / stdWrap

The first item to return. If not set (default), items beginning with the first one are returned.

maxItems

maxItems
Data type

integer / stdWrap

Maximum number of items to return. If not set (default), all items are returned. If begin and maxItems together exceed the number of available items, no items beyond the last available item will be returned.

renderObj

renderObj
Data type

cObject +optionSplit

The cObject used for rendering the files. It is executed once for every file. Note that during each execution you can find information about the current file using the getText property "file" file with the "current" keyword. Look there to find out which properties of the file are available.

Example:

page.10.renderObj = TEXT
page.10.renderObj {
  stdWrap.data = file:current:size
  stdWrap.wrap = <p>File size:<strong>|</strong></p>
}

This returns the size of the current file.

stdWrap

stdWrap
Data type

->stdWrap

Special key: "references"

references.table

references.table
Data type

string / stdWrap

The table name of the table having the file field.

references.uid

references.uid
Data type

integer / stdWrap

The UID of the record from which to fetch the referenced files.

references.fieldName

references.fieldName
Data type

string / stdWrap

Field name of the file field in the table.

Examples

Usage with files

In this example, we first load files using several of the methods explained above (using sys_file UIDs, collection UIDs, and folders). Then we use the TEXT cObject as renderObj to output the file size of all files that were found:

page.10 = FILES

page.10.files = 12,15,16
page.10.collections = 2,9
page.10.folders = 1:mypics/

page.10.renderObj = TEXT
page.10.renderObj {
    stdWrap.data = file:current:size
    stdWrap.wrap = <p>File size: <strong>|</strong></p>
}

Usage with references

In this second example, we use "references" to get the images related to a given page (in this case, the current page). We start with the first image and return up to five images. Each image is then rendered as an IMAGE cObject with some meta data coming from the file itself or from the reference to it (title):

page.20 = FILES
page.20 {
    references {
        table = pages
        uid.data = tsfe:id
        fieldName = media
    }

    begin = 0
    maxItems = 5

    renderObj = IMAGE
    renderObj {
        file.import.dataWrap = {file:current:storage}:{file:current:identifier}
        altText.data = file:current:title
        wrap = <div class="slide">|</div>
    }
    stdWrap.wrap = <div class="carousel">|</div>
}

Usage with sliding

One usual feature is to use images attached to pages and use them up and down the page tree, a process called "sliding".

lib.banner = FILES
lib.banner {
    references {
        data = levelmedia: -1, slide
    }

    renderObj = IMAGE
    renderObj {
        file.import.dataWrap = {file:current:storage}:{file:current:identifier}
        altText.data = file:current:title
        wrap = <div class="banner">|</div>
    }
}