PHP

Custom Functions
Custom functions provide a quick and easy way to add your own functionality to a theme using plain PHP. In contrast to extensions, custom functions are not meant to be distributed as separate packages. Instead, they live right inside your theme and can be defined in a single statement without the need for any class files or autoloading setup. Once defined, a custom function is used in templates just like any other function.
Inline PHP
Since templates are regular .php files, Automad also supports plain PHP within templates. However, variables that are only used in PHP code don't show up automatically in the dashboard and mixing PHP with the template language should be done carefully. Therefore it is not recommended to use large amounts of plain PHP in templates. Missing functionality should rather be implemented as a custom function or an extension, where the PHP code is nicely wrapped into a statement that integrates well ...
Generic Extensions
In case you are missing an advanced feature while developing themes using the template language, you can implement that functionality as a generic extension written in plain PHP. Generic extensions have full access to all content and core features and can be used in any template of any theme.
Custom Filters
Automad already provides a set of filters to modify the value of a variable. However, in some cases it may be necessary to use a custom function to process the content of a variable. Custom filters are written in plain PHP and their setup is very similar to the structure of a generic extension.
Plain PHP Snippets
In case you want to develop a custom function or an extension, or use inline PHP in your templates, the collection of common code snippets below might help you to get started quickly. Within templates, the $Automad object is always available. Custom functions and extensions receive it as an argument.