Controls
Add Control
Each block has options to let the user customize it, you need to create block controls by clicking on the "Add Control" button. You can create as many controls per block as you want.
Control Settings
These settings will be available for most of the control types.
- Label – Display label. This name will be shown on the Gutenberg editor inside block settings
- Name – Control name, that will be available by accessing it in HTML code output. This name should be unique in the current block
- Type – Control type. There are available several types such as Text, Select, Toggle, Image, etc…
- Default value – Default control value
- Help text – Help text will be added under control
- Placement – Control placement. Available placements and description read below on this page
- Width – Control width for controls inside Content. 25%, 50%, 75% and 100%
- Required – Makes the control required. Displays the warning and prevents page publishing when the control is not filled
- WPML Translation – Makes Text controls available for translation in WPML plugin. Learn more here
- Hide if block is not selected – hides control from the Content when block unselected
- Save in Meta – Save control value in the custom meta field. Read more info on this page below
- Conditional Logic – Conditionally display/hide controls
Extra settings:
- Different controls contain a set of extra settings. Learn more on separate documentation pages for controls
Control Placement
Control can be added in 2 places: Inspector and Content (inside block body). Example:
Custom Meta Field
Each control has the possibility to save its value in the custom fields, so this value will be available in the post meta data and developers may get this value. For example:
<p><?php echo get_lzb_meta( 'control_meta_name' ); ?></p>
You should add a unique custom field name, as 3rd-party plugins/themes may use the same name and it will be conflicted. For example, if you want to use this block in your theme "My Super Theme", we recommend adding slug name – mst_control_meta_name.
Reserved Control Names
There are reserved control names that you shouldn't use:
Name | Description |
---|---|
lazyblock | internal block data used by Lazy Blocks plugin |
className | block custom classname |
align | block align |
anchor | block custom ID |
blockId | block unique ID, generates automatically |
blockUniqueClass | block unique class, generates automatically |