Page Access
Use page gates to limit access to paid content like courses, lessons, or downloads.
Blueprint field
site/blueprints/pages/course.yml
title: Course
fields:
gates:
extends: fields/klub/gates/plans
text:
label: Content
type: textarea
The field key defaults to gates and is defined by ProviderGates::$field.
Panel selection
Once provider plans are configured, the gates field lets you select price IDs directly in the Panel. Provider data is cached, so plan changes may take a few minutes to show up.
Template checks
<?php if ($page->isAllowed()): ?>
<p>Allowed content</p>
<?php else: ?>
<p>Upgrade to access this page.</p>
<?php endif ?>
You can also use the snippet:
<?php snippet('klub/allows', slots: true) ?>
<?php slot('isAllowed') ?>
<p>Allowed content</p>
<?php endslot() ?>
<?php slot('isNotAllowed') ?>
<p>Upgrade to access this page.</p>
<?php endslot() ?>
<?php endsnippet() ?>
Filtering page collections
<?php foreach ($page->children()->removeNotAllowed() as $child): ?>
<a href="<?= $child->url() ?>"><?= $child->title() ?></a>
<?php endforeach ?>