Module variables for Twig
When adding an ACF Field Module or Timber Posts Module you will have the option to write a Twig template for it. There are a few default variables that you can use on each of them.
Toolbox Field Module
Every time you add an Toolbox Field Module to the layout and you start writing your template, you will have access to these three variables:
__field__ (mixed)
__field__object (array)
post (object)
Timber Posts Module
The Timber Posts Module is used to render data using the Main Query or Custom Query. You can also use it to render, well, pretty much whatever you want.
The Timber Posts Module has access to the following variables:
post (object)
posts (array)
module (array)
The fields explained
__field__
This variable is the value as returned by the toolbox/helpers/get_acf_field/type={fieldtype}
filters. When using twig with simple fieldtypes it will be a string, but for the relational fields it will be an array, containing the value as returned by ACF.
__field__object
This variable is the value as returned by ACF, using the get_field_object()
function. It is useful because as opposed to the __field__
variable it contains all information stored in the database on that particular field by ACF. It might come in handy if you need the unselected options from a checkbox field for instance. The __field__
variable will only have the selected values.
post
If you’re displaying a singular page or post you will have access to the post-data. Because the post
variable is inserted using Timber, it has much more information that is very easy to access.
If you’re not on a singular page or post, the value of post
will be NULL.
posts
Only the Timber Posts Module has access to this variable. The posts
(plural) variable is an array of objects, containing zero to many objects.
module
The module
variable contains the following three sub variables:
module.module
module.id
module.settings
These are the variables as described in the BB documentation, cast to array.