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
Presets
It might be the case that you want to guide the user which blocks to add on certain pages. You can use so called "presets" to do this.
Just add a hook that returns an array of block-types in your /site/ready.php file:
wire()->addHookAfter(
'RockPageBuilder::getPresets',
function (HookEvent $event) {
$page = $event->arguments(0);
$field = $event->arguments(1);
if ($page->template != 'blogitem') return;
if ($field->name != 'rockpagebuilder_blocks') return;
$event->return = [
'Demo' => [
'Alert',
'Features',
'Features',
'Videos',
],
];
});
You can have as much presets as you want and you can granularly define where they should be shown via if conditions in the hook.