What is mp4
? What type of field?
it’s the name of the block that query the audio block, and it’s the field that query
here is the mp4.yml
name: Leçons (lien)
label: "{{ kirby.page('espaces/mini-lecons').contenu.toBlocks.filterBy('type', 'audio').title }}"
fields:
mp4:
type: select
help: Liens vers les Mini-leçons
empty: "Aucune Mini-leçons en lien pour l'instant"
options: query
query:
fetch: kirby.page('espaces/mini-lecons').contenu.toBlocks.filterBy('type', 'audio')
text: "{{ block.title }}"
value: "{{ block.id }}"
But $block->mp4()
is not a blocks field but a select field, so you cannot call toBlocks()
on it.
This field stores the an ID of one of these blocks
kirby.page('espaces/mini-lecons').contenu.toBlocks.filterBy('type', 'audio')
So you would have to find the block in these blocks by id:
$audioBlocks = page('espaces/mini-lecons')->contenu()->toBlocks()->filterBy('type', 'audio'):
$wantedBlock = $audioBlocks->findBy('id', $block->mp4()->value());
Once again, you’re great. Thank you, I don’t how I could have find it myself (I can barely see me starting to understand…).
To answer your question
Why do you need the nested structure in the audio block instead of creating a block per audio file?
For me it made more sense to have a lesson for the neck, with a title and presentation and then a bunch of audiofiles with titles of those lessons, and another lessons for the feet with title, presentation, files… than having a block for the title and presentation of the lesson for the neck, then a block per file, another block for the title and presntation of lesson for the foot and files… for example, if I want to move the order of the lessons, just having to move two blocks, and not a serie of block. At one point I remember reading it was not recommended to have nested blocks, that’s why structure had seem appropriate.
One last question concerning the title, because at this point I see it will take me a lot time of trial and error and error, with your help I see the queried title, but have no clue as to past it to the label, label: "{{ kirby.page('espaces/mini-lecons').contenu.toBlocks.filterBy('type', 'audio').title }}"
can you show me/make me start to understand how to achieve that, thanks
This query
kirby.page('espaces/mini-lecons').contenu.toBlocks.filterBy('type', 'audio')
Returns a collection, not a single element, so it doesn’t have a title attribute.
Where does this label belong to?
It’s like a Kōan…
I would say it belongs to the audio.yml, it’s its title. I have no clue how to make it emerge,
.findBy(‘block’, ‘title’)
sorry
And I think I have lost track…
…me too, thank you, good weekend