Getting files from files section

This is most possibly very simple and I am most possibly dense, but… how do I get files from a file section?

my yaml:

    headline: Programa
    type: files
    template: programa
    max: 1

…there is a file in there, a pdf, but If in my template I do

<?php dump($page->programa()) ?>

I get what looks like an empty object…

Kirby\Cms\Field Object
    [programa] => 

The following does not seem to work neither (nothing is echoed):

    <?php if ($page->programa()->isNotEmpty()): ?>
        <a href="<?= $page->programa()->toFile()->url() ?>" class="programa">PROGRAMA</a>
    <?php endif ?>

Perhaps I have to use toFiles() (plural) and loop ? But why would the object seem empty?

Thank you

You don’t get anything from a section, it doesn’t store anything in the content files.

You get the files via the template you assign to them in the section:

$files = $page->files()->template('programa');
1 Like