I have an issue with block content not showing up. I have used blocks before and followed the same structure so I’m not sure what I’m doing wrong.
I’ve set up some basic page structure. Everything here is rendering except the blocks.
I’ve added an empty
Tempalte
<?php snippet('header') ?>
<section class="">
<?= $page->heroWrittenContent() ?>
<?php if ($file = $page->heroVisualContent()->toFile()): ?>
<?php if ($file->type() === 'image'): ?>
<img src="<?= $file->url() ?>" alt="<?= $file->alt() ?>">
<?php endif ?>
<?php if ($file->type() === 'video'): ?>
<div class="" style="background-image: url(<?php if($poster = $page->videoPoster()->toFile()): ?><?= $poster->url() ?><?php endif ?>);"></div>
<video autoplay playsinline prelaod muted loop><source src="<?= $file->url() ?>" alt="<?= $file->alt() ?>" type="video/mp4"></video>
<?php endif ?>
<?php endif ?>
</section>
<!-- Builder Section -->
<?php foreach ($page->pageBuilder()->toBlocks() as $block): ?>
<?= $block ?>
<div>
</div>
<?php endforeach ?>
<?php snippet('footer') ?>
A block (in site/snippets/blocks/filename.php)
<section>
<?= $block->sectionHeading() ?>
<?php if($linkedPage = $block->linkedPage()->toPage()): ?>
<a href="<?= $linkedPage->url() ?>" class=""><?= $block->buttonContent()->upper ?></a>
<?php endif ?>
</section>
The template blueprint
title: Page Builder
tabs:
main:
icon: document
columns:
heroVisualContent:
width: 1/2
sections:
heroVisualContent:
type: fields
fields:
heroVisualContent:
label: Hero Background
type: files
max: 1
videoPoster:
label: Poster Image
help: If the backgound is a video this image will shown while the video loads
type: files
max: 1
heroWrittenContent:
width: 1/2
sections:
heroWrittenContent:
type: fields
fields:
heroWrittenContent:
label: Hero Text
type: textarea
size: medium
buttons: false
contentMain:
width: 1/1
sections:
pageBuilder:
type: fields
fields:
pageBuilder:
label: Page Builder
type: blocks
fieldsets:
text:
label: Text
type: group
fieldsets:
- one_column_text
- two_column_text
- image_with_text
- sticky_image_scroll
An example of a block blueprint
type: Single-Column-Text-Block
name: Single Column Text Block
icon: text-justify
wysiwyg: true
preview: fields
fields:
gap:
type: gap
width: 1/6
textContent:
label: Text Contnet
type: writer
width: 2/3
marks:
- bold
- link
- email
nodes:
- heading
- paragraph
- bulletList
- quote
What I see in inspector
