Hey I got problem with the blocks function.
I have used blocks before, and it is super wired that they are not working this time. So I am hoping that someone could point me in a direction for my troubleshooting.
Here is what works:
- panel – custom blocks are visible
- blueprints – for the custom blocks are connected
What doesn’t work:
- calling the blocks with the
toBlocks()
method in the template.
What I have tried so far:
- checking for any misspelling
- using the
toBlocks()
method in another scope - Reducing the complexity of the block snippet (that does not seems to be the problem)
- renaming the field with the type: blocks in the page yml
- compared (a lot) with other projects where it works
- checking the kirby version: 3.6.0
The thing is, that is no fancy approach in the case. The template seems simply to not get the blocks I set up in the panel:
I this embla__container should be the block.
Template: templates/project.php
<?php snippet('header') ?>
<?php snippet('topLine2') ?>
<div class="grid_wrapper">
<div class="embla slider img_slider">
<div class="embla__container">
<?= $page->content()->toBlocks(); ?>
</div>
</div>
</div>
<?php snippet('bottomLine2') ?>
<?php snippet('footer') ?>
Page blueprint: blueprints/pages/project.yml
title: project
icon: 🖼
columns:
- width: 1/1
sections:
imageslider:
type: fields
fields:
content:
type: blocks
fieldsets:
- datei
- reihe
- width: 1/2
sections:
generell:
type: fields
fields:
meta:
type: textarea
buttons: false
cover:
type: radio
options: query
query: page.files
Block Snippet: snippets/blocks/datei.php
<figure class="embla__slide image_Column slide-<?= $block->indexOf() ?> <?= $block->image()->toFile()->orientation() ?>">
<img class="img_Container <?= $block->image()->toFile()->orientation() ?>" src="<?= $block->image()->toFile()->url() ?>" alt="<?= $block->image()->toFile()->alt() ?>">
</figure>
Block blueprint: blueprints/blocks/datei.yml
name: Bild/Video
icon: image
preview: image
fields:
art:
label: Art
type: radio
columns: 2
default: "bild"
options:
bild: Bild
video: Video
image:
label: field.blocks.image.name
type: files
query: page.images
multiple: false
layout: cards
size: huge
image:
back: black
uploads:
template: project_Image
when:
art: bild
video:
label: Videolink
type: text
when:
art: video
title:
type: text
text:
type: textarea
For me it looks like in the textbook.