File tree

This widget renders a file picker allowing to choose one or more files from the file system.

The file tree widget in the contao download element:

File tree widget

The file tree with gallery option enabled (as in the contao gallery element):

File tree widget

Options

This table only shows the options relevant to the core functionality of this widget. See the DCA reference for a full field reference.

KeyValueDescription
inputTypefileTree (string)
eval.extensionsstringLimits the file tree to certain file types (comma separated list).
eval.fieldTypecheckbox/radio (string)checkbox allow multiple selections
radio allow a single selection only
eval.filesboolIf true files and folders will be shown. If false, only folders will be shown.
eval.filesOnlyboolRemoves the radio buttons or checkboxes next to folders.
eval.isGalleryboolDisplays selected files of a fileTree widget as an image gallery.
eval.isSortableboolsince 4.10 Enable sorting for the selected items.
eval.multipleboolMake the input field multiple.
eval.orderFieldstring

Using “orderField” for the page tree has been deprecated and will no longer work in Contao 5.0. Use “isSortable” instead.

Database column where the order of the selected items gets stored. This is only required if isGallery or isDownloads is set.
eval.pathstringCustom root directory for file trees.

Examples

A single image file picker.

// ...
'singleSRC' => [
    'exclude'   => true,
    'inputType' => 'fileTree',
    'eval'      => [
        'filesOnly'  => true,
        'fieldType'  => 'radio',
        'extensions' => '%contao.image.valid_extensions%',
    ],
    'sql'       => [
        'type' => 'binary',
        'length' => 16,
        'fixed' => true,
        'notnull' => false,
    ],
],
// ...

An image gallery picker, allows picking multiple images, display them in the back end as gallery and be able to sort them.

// ...
'multiSRC' => [
    'exclude'   => true,
    'inputType' => 'fileTree',
    'eval'      => [
        'fieldType'  => 'checkbox',
        'files'      => true,
        'isGallery'  => true,
        'multiple'   => true,
        'extensions' => '%contao.image.valid_extensions%',
        'orderField' => 'orderSRC',
    ],
    'sql'       => "blob NULL",
],
// ...

A folder picker.

// ...
'folders' => [
    'inputType' => 'fileTree',
    'eval'      => [
        'files'     => false,
        'fieldType' => 'checkbox',
        'multiple'  => true,
    ],
    'sql'       => "blob NULL",
],
// ...

Usage in Contao

The file tree widget is used very often in contao. Examples are the text, download, image and gallery elements.