Skip to content
  1. Extras
  2. PageBuilder
  3. Field types
  4. Free
  5. file

Field file

Version: Free.

Why this type

Enrich adds filename, extension, size, url. Fits PDF, archives, not only images. Same media pipeline as image.

When to use

  • PDF price list, deck, downloadable asset
  • Attachment in contact or CTA
  • Any file from MODX media

Tips

In chunk use {$file.url}, not raw path. Photos alone often use image.

Similar types

  • image for photos with alt and dimensions
  • url for external link without upload

Schema

json
{
  "name": "pdf",
  "type": "file",
  "label": "File",
  "description": "PDF or another document",
  "tab": "Content",
  "width": 100,
  "active": true
}

Value

Media object: url, size, title, name, filename, extension, type, and more. A legacy string on read is wrapped as { url }.

Section data

Key pdf in the section data after save enrich (MediaFieldEnricher):

json
{
  "pdf": {
    "url": "assets/files/catalog.pdf",
    "id": 34,
    "path": "assets/files/",
    "filename": "catalog.pdf",
    "extension": "pdf",
    "name": "catalog",
    "title": "catalog.pdf",
    "size": 1048576,
    "type": "pdf"
  }
}
  • A legacy URL string is normalized to { url } on read.

Chunk example

html
<a href="{$pdf.url|escape}" download="{$pdf.title|escape}">{$pdf.title|escape}</a>

Common properties

For fields with name that are stored in the section data:

KeyTypeRoleCMP
tabstringGroup subtitle in the inspectoryes
width25–100Field width as % of the row (flex)yes
descriptionstringHint under the labelyes
defaultanyInitial value for a new sectionyes
activeboolfalse hides the field in the inspectoryes
requiredboolRequired on publish (draft still saves)yes
  • Also in schema: media object, enrich on save.

See fields overview.

See also