This plugin requires Craft CMS 4 or later.
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require nicholashamilton/craft-preview-mate
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for PreviewMate.
<?php
return [
"matrixFields" => [
[
"handle" => "pageBuilder",
"excludedBlocks" => [
"rowContainer",
],
],
[
"handle" => "ctaBlocks",
],
],
];
Each block/ element rendered from a Matrix Field needs either of the two tags in order to work with Live Preview click and scroll.
{# option 1 #}
{{ craft.previewMate.previewBlock("replaceWithMatrixFieldHandleHere") }}
{# option 2 #}
preview-block="replaceWithMatrixFieldHandleHere"
{% set matrixHandle = "pageBuilder" %}
{% set blocks = entry[matrixHandle].all() %}
{% for block in blocks %}
<div {{ craft.previewMate.previewBlock(matrixHandle) }}>
{{ include("_blocks/" ~ block.type.handle|kebab) }}
</div>
{% endfor %}
[preview-block] {
position: relative;
}
[preview-block]::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 1px dashed rgba(0, 0, 0, .333);
pointer-events: none;
opacity: 0;
transition: opacity 300ms ease;
}
[preview-block].is-hovering::after {
opacity: 1;
}