Field methods are registered with the
Default field methods
For a full list of default field methods, please check out the Reference.
Be aware that you cannot override these default field methods with any custom field method.
This example shows the basic architecture of creating a new field method. You define the method name with the array key for the
fieldsMethod array. The callback function receives the
$field object as first argument.
How to use your new field method
The object passed to the callback function gives you access to three important attributes.
||Name of the field|
||Raw content of the field|
There are three common scenarios, what field methods can do:
1. Modifying the field for further chaining
If you want to make it possible that the field value can be further modified by other field methods, you must modify the field value by overwriting/modifying
$field->value and returning the
2. Directly returning a modified value
When you directly return the modified value, further chaining is not possible.
3. Returning info about the field
Field methods can also be used to make if clauses easier or return info about a value, such as the length or the readingtime.
Working with method arguments
In some cases it might be helpful to be able to pass arguments to the method:
The definition for such a method with arguments is very simple: