Video block doesn't show up

blueprint:

fields:
    titel:
      label: Filmtitel
      type: text
    videos:
      type: blocks
      fieldsets:
        media:
          type: group
          fieldsets:
            #  - image
              - video
    description:
        label: Beschreibung
        type: text

template:

    <h2><?= $page->titel()->html() ?></h2>
    <div>
        <?= $page->videos()->toBlocks() ?>
    </div>
    <p><?= $page->description()->html() ?></p>

The title field and the description render just fine, but the video embed doesn’t.

I actually just need a simple video field for youTubes and Vimeos, but I couldn’t find one in the docs, so I took a block with just a video block.

That is because videos is a native Kirby method ($page->videos() | Kirby CMS).

See also naming fields: Fields | Kirby CMS

You can get the field via

<?= $page->content()->get('videos')->toBlocks() ?>

Or rename your field to something else.

Yes, it was the field name. I thought the forbidden name was “video”.

But still, what is the blueprint field type for video if it isn’t a block? Can I only have a blocks field to have a video field? I couldn’t find it in the docs.

You would use a files field and limit what type of files can be uploded via a file blueprint (using the accept option (if you want to use a video file).

If you only want to use a video url, you can use a url field, that’s what’s used in the video block as well. There is no video field type.

Maybe there should be one?

A video embed isn’t really a file that you upload to a site, thats why I thought that would be the wrong way to do it. The files field I think of as something to upload and then present it to the user like an image or for downloading it like a PDF, but a video embed feels different to me. But maybe that’s really just me.

I didn’t say you should upload a video. As I said, use a url field to put your video url into.

This is the video block blueprint:

name: field.blocks.video.name
icon: video
preview: video
fields:
  url:
    label: field.blocks.video.url.label
    type: url
    placeholder: field.blocks.video.url.placeholder
  caption:
    label: field.blocks.video.caption
    type: writer
    inline: true

It uses a url field as well.

If you want, you can add a validator to the field that checks for youtube/vimeo urls.

Äh… right.

PS: That video blocks blueprint I got from the starter kit that I used this time.

Aaaand more than a year later I completely forgot that ‘videos’ is a native Kirby Method, so I made the same mistake just simply again. Searched the forum and found the solution in my own question from last year. Boom, its so easy (without a brain).

2 Likes