Blocks
Block Blueprint
Similar to pages, you can limit access blocks. When defining your custom blocks include the gates field.
site/blueprints/blocks/example.yml
name: Example Block
preview: fields
wysiwyg: true
fields:
gates:
extends: fields/gates/plans
# or extends: fields/klub/gates/plans
text:
label: Text
type: textarea
Filtering Blocks by Gates in PHP
You can use the removeNotAllowed
-BlocksMethod from the Klub plugin to remove Blocks from a BlockCollection that the current user cannot access.
site/templates/lesson.php
foreach ($page->blocks()->toBlocks()->removeNotAllowed() as $block) {
// ...
}