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.

Key Value Description
inputType fileTree (string)
eval.extensions string Limits the file tree to certain file types (comma separated list).
eval.fieldType checkbox/radio (string) checkbox allow multiple selections
radio allow a single selection only
eval.files bool If true files and folders will be shown. If false, only folders will be shown.
eval.filesOnly bool Removes the radio buttons or checkboxes next to folders.
eval.isGallery bool Displays selected files of a fileTree widget as an image gallery.
eval.isSortable bool since 4.10 Enable sorting for the selected items.
eval.multiple bool Make the input field multiple.
eval.orderField string

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.path string Custom 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.