Extension Usage

Extensions provide a convenient way of turning custom PHP code into statements of the template language. Besides the fact that extensions are always called by their full name including their namespace, the syntax is the same as for regular functions and pipe functions.

<# Generic extension. #>
<@ Vendor/Extension { options } @>
<# Custom pipe function. #>
@{ variable | Vendor/Name }

Installing Extensions

Extensions are distributed as packages and can be installed using the package manager in the dashboard. Packages that are not published can also simply be copied into the packages directory of your installation. After installation, an extension is available in all templates of all themes.

Generic Extensions

Generic extensions are used like functions. Options are passed as a relaxed JSON object and can contain variables and pipe functions. Whatever is returned by the extension is rendered in place of the statement.

<@ Vendor/Gallery {
  glob: @{ galleryFiles | def ('*.jpg') },
  width: 400,
  class: 'gallery'
} @>

Custom Pipe Functions

Custom pipe functions are used like any built-in pipe function and can also be chained with other pipe functions. Parameters are passed in parentheses.

@{ title | Vendor/Slugify | strtoupper }
@{ text | Vendor/Truncate (100, '...') }

Precedence

When a statement is called, Automad first looks for a matching snippet, built-in function or custom function before trying to load an extension. Since extension names always contain a namespace, conflicts with other statements are practically impossible.

Inheritance Recurisve Navigations