Skip to content

Template types

The template name starts with a prefix, and the prefix decides where it is read from.

PrefixSourceExample
@INLINEtemplate code in the string itselfview('@INLINE Hello, {$name}')
@FILE / file:a file under pageblocks_elements_pathview('file:blocks/card.tpl')
@PATH / path:a file at an arbitrary pathview('path:assets/chunks/hero')
template:a MODX template from the databaseview('template:base')
no prefixa MODX chunk (modChunk) by nameview('header')

There is no fallback

The prefix picks one source, it does not define a search order. view('header') looks for a chunk named header and does not then try files; view('file:header') looks for a file and never looks at chunks. When nothing matches, MODX logs [Fenom]: Template … not found and the call returns an empty string. A blank spot on the page instead of an error is almost always this.

Extension

File templates (file:, path:) may omit the extension — .tpl is appended. An existing .tpl or .html is taken as is; any other extension is not recognised as one and .tpl gets appended on top of it.

php
view('file:blocks/article');       // → blocks/article.tpl
view('file:blocks/article.tpl');   // → blocks/article.tpl
view('file:mail/invoice.html');    // → mail/invoice.html

📁 Where file templates live

file: and @FILE are resolved against pageblocks_elements_path, core/App/elements/ by default:

php
view('file:blocks/article.tpl');
// => looks for: core/App/elements/blocks/article.tpl

path: and @PATH carry the directory themselves and ignore pageblocks_elements_path. The path is site-relative or absolute, understands the {core_path}, {base_path} and {assets_path} placeholders, and may not contain ..:

php
view('path:assets/chunks/hero');            // → /assets/chunks/hero.tpl
view('path:{core_path}elements/mail/ok');   // → core/elements/mail/ok.tpl

This is the same mechanism as the block's Chunk directory field (chunk_path): it lets chunks sit next to the code that uses them instead of piling up in one directory.

Inside a template

The same prefixes work in {include}, {extends} and {insert} — they are engine providers, not view() parsing:

fenom
{extends 'file:templates/base.tpl'}
{include 'path:assets/chunks/hero'}
{include 'header'}            {* no prefix - a MODX chunk *}

Files only

With pageblocks_file_elements_only = true the template: provider is not registered at all, and any unprefixed name is treated as file:. Database chunks stop being reachable — both from view() and from {include}.

© PageBlocks 2019-present