Custom Fields
You will find an example of a post with custom fields when you install b2evolution with the demo content:
Defining custom fields
You can define custom fields in the Item Type Form.
Custom fields can have different types: numbers (floating-point numbers with double precision), text strings (varchars), URLs, text, etc.
You can define as many custom fields of each type as you want and give them a name each. Each custom field has a field index that can be generated from the field name. The field index is the trimmed lowercase value of the field name where the white spaces are converted to one single underline character. Field indexes must be unique in a collection ( this way field names are also unique ).
Sample field names and corresponding field indexes:
- ‘Color’ =>
color
- ‘Name of custom field’ =>
name_of_custom_field
- ‘Max speed (km/h)’ =>
max_speed_km_h
Entering data into custom fields
The fields defined here will appear in the Custom Fields section of the Item Edit Screen.
Displaying the data entered in custom fields
There are 3 ways to display custom fields:
- With a widget: Item Custom Fields Widget
- From within the post contents, by using Custom Fields Short Tags
- From within a skin template, with PHP code: Displaying Custom Fields in a Template