FILES

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

Properties

cache

cache
Type
cache

See cache function description for details.

files

files
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
Copied!

references

references
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
Copied!

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
}
Copied!

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

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

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

collections

collections
Type
string / stdWrap

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

folders

folders
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/
Copied!

Example for option recursive:

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

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

sorting

sorting
Type
string / stdWrap

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

sorting.direction

sorting.direction
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
Type
integer / stdWrap

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

maxItems

maxItems
Type
integer / stdWrap

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

renderObj

renderObj
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>
}
Copied!

This returns the size of the current file.

stdWrap

stdWrap
Type
->stdWrap

Special key: "references"

references.table

references.table
Type
string / stdWrap

The table name of the table having the file field.

references.uid

references.uid
Type
integer / stdWrap

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

references.fieldName

references.fieldName
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 Properties 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>
}
Copied!

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>
}
Copied!

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>
    }
}
Copied!