Skip to content

Settings ​

Three MODX system settings, area parser:

SettingWhat it doesDefault
pageblocks_elements_pathDirectory of file templates for @FILE and file:.{core_path}App/elements/
pageblocks_file_elements_onlyRead templates from files only, never from database chunks.false
pageblocks_fenom_auto_reloadRecompile a template when its file changes.true

The same area holds a fourth key, pageblocks_default_chunks, which is not yours to fill in: it stores the sha1 of every shipped default chunk so an upgrade can tell your edits from ours. Emptying it only makes the next upgrade treat every default as edited.

The path is absolute, not "relative to core/"

The value goes into a filesystem path verbatim, so it has to be absolute. MODX expands the {core_path}, {base_path} and {assets_path} placeholders itself — that is what the {core_path}App/elements/ default relies on. Writing App/elements/ does not work: it resolves against the current working directory, the directory is not found, and MODX logs [Fenom Init] Template directory does not exist.

pageblocks_file_elements_only ​

The flag means "elements from the database are forbidden" — not "read an unprefixed name as a file". For projects that keep elements in git rather than in the database.

  • view() / &tpl with an unprefixed name is an error, with the fix spelled out in the log: file elements only mode is on, so 'card' has nowhere to come from: name the source - file:card;
  • inside a template the default provider becomes the file one, so {include 'header'} looks for header.tpl on disk;
  • the template: provider is not registered at all;
  • default chunks of the component keep working — they are resolved past this setting on purpose, so a snippet called without &tpl still renders.

Why an error rather than a silent substitution

Because otherwise the same call means different things on different sites: a copy-paste from this documentation would stop working with no explanation, and a designer who created the chunk in the manager would have no way to find out why it was ignored. A global flag that silently rewrites the syntax also makes a mixed project impossible.

pageblocks_fenom_auto_reload ​

Turning it off in production only makes sense where templates do not change between deploys: with it off, editing a .tpl has no effect until the cache is cleared. In pbFenom the freshness check is cheap — realpath() was taken off the hot path, and a page with {extends} plus twenty {include} costs 7.6 µs against 4.5 µs without auto reload — so there is not much to save here.

Fixed in code ​

The rest comes from View::init() and is not configurable:

OptionValueWhy
compile directorycore/cache/pbfenom/cleared together with the MODX cache
force_includetrue{include} is compiled into the parent's body
force_verifytruean undeclared variable is an empty string, not a warning
force_compile, disable_cachefalsethe artifact is written to disk and reused
disable_native_funcsnot setsee PHP functions

Clearing the cache ​

Compiled templates live in core/cache/pbfenom/. Clearing the cache from the MODX manager runs:

php
View::clearCache();

Clearing the directory by hand is not needed — with auto_reload on, editing a file already triggers a recompile.

© PageBlocks 2019-present