Getting field information and dealing with errors

Estimated reading: 2 minutes

You might wonder what you can do with the field value. First all filters are applied that you may have define using the toolbox filters before passing it to the Timber template filter.

Simple fields will have a value of type string, whereas relational fieldtypes will be passed in as an array of values.

Debugging your Twig template

You can use almost any regular PHP function in Twig. This means that you can use:

{{ tb.var_dump( __field__ ) }}

To view the value of any variable or object.

Hiding the output for visitors

You might want to see the values but only when editing in the Beaver Builder, for quick debugging. You can add a filter called ‘fl_builder’.

If you pipe the |fl_builder filter before outputting it, the output will only render when you are logged in and editing the post. So you will be able to see the variable settings, but not the visitors of your site.

{{ tb.var_dump(__field__)|fl_builder }}

Dealing with errors

If a template used in a module runs into an error, it will return the module’s content silently without crashing the whole page. In most cases the rest of the layout will continue to render as normal.

While developing it might be useful to see what those errors actually are.

For this, you can enable the option “Enable Twig Debug Messages on failure” on the “Toolbox Settings > Timber Templates tab” in your dashboard.

Share this Doc

Getting field information and dealing with errors

Or copy link

CONTENTS