Panel select box with files from another page

I’m trying to have something in my blueprint that would look like this:

  documents:
    label: Associated Documents
    type: structure
    style: table
    fields:
      filename:
        label: Document
        type: select
        options: files

Except, with the file list coming from a different page where all of the documents are stored instead of having them scattered through the pages (also there is a fair bit of overlap) I took a look at “hooks,” but I’m having trouble understanding how to use them. Any tips? thank you!

I don’t quite understand what you want to do with hooks here? What exactly do you want to achieve?

Just a selectbox (in a structured field) with a list of files that originate from a different page.

Oh, I see, you can use

documents:
  label: Associated Documents
  type: structure
  style: table
  fields:
    filename:
      label: Document
      type: select
      options: query
      query:
        page: the_name_of_page
        fetch: files

Cooool, thank you. I don’t know how I missed the “query” option in the documentation.

OK, so, I ended up with this:

    manuals:
        label: Manuals
        type: structure
        style: table
        fields:
          filename:
            label: Document
            type: select
            options: query
            query:
              page: manuals
              fetch: files
              value: '{{filename}}'
              text: '{{filename}}' 

But, I’m having a little trouble in the template code. So far I have:

<?php foreach($page->manuals()->toStructure() as $pdf): ?>
	<li>
		<a href="../manuals/<?php echo $pdf->filename() ?>" target="_blank">
			<?php echo $pdf->filename() ?> [<?php echo $pdf->niceSize() ?>]
		</a>
	</li>
<?php endforeach ?>

(sorry the indentation is gone, I can’t get the four space thing to work at the moment)
So, to get the link to point to the right place I have that relative path which works fine (but possibly isn’t best practice?), but it’s not retrieving the niceSize. This isn’t crucial, but would be nice.

You need to convert the filename to a file object:

$file = $page->file($pdf->filename());

It will have all properties like url and niceSize.

Please click the edit button of your post. I have fixed your code block syntax there and you can take a look at it (basically three backticks and in separate lines).