Getting Started
Features
- API
- Blocks
- Blocks with JS
- Helper Classes
- Block Fields
- Accessing Fields
- Text Margin
- Presets
- Block Settings
- Drag & Drop Sortable
- Block Spacings
- Custom Block Stubs
- Widgets
Requirements
PHP>=8.0ProcessWire>=3.0.227RockMigrations>=3.30.0RockFrontend>=3.6.0- API
Accessing Fields
All fields of your block will be available to your $block
variable just like usual:
echo $block->your_field_name;
echo $block->edit('your_field_name');
Method Syntax
RockPageBuilder comes with a helper to make working with long fieldnames easier and less verbose. The reason for that is that when I create new blocks I always prefix all fields with the block template name. That way I can be sure that when I copy that block to another project the fieldnames don't collide with existing fields.
The problem here is that we end up with long fieldnames like this: rockcommerce_invoice_pdf
.
When using RockPageBuilder you can do this:
echo $block->pdf();
This feature is actually a feature of RockMigrations' MagicPages module. You can also pass parameters to request a different state of the field:
$block->pdf(); // frontend editable field
$block->pdf(1); // using ->getFormatted()
$block->pdf(2); // using ->getUnformatted()
Note that the method call has to be the last part of the string after the final underscore:
// field foo_bar_baz
$block->baz()
// field foo_something
$block->something()