I canât manage to set up a layout in my php template, i copy the code from the documentation, but my hello div is never rendered, as if my it cannot start the foreach loopâŚ
i donât know what i should write in my css, for the .grid, .column and .blocks
Basically what i want to achieve is something of a masonry grid, that i can manipulate from the panel. I thought the layout field could be interesting, at least what it looks like in the panel is the very thing i want
Your layout field is called images so the loop should be:
<?php foreach ($page->images()->toLayouts() as $layout): ?>
However you wil probably get an error with that as it will clash with the built in images method. you need to rename the layout. I would suggest calling it something like gallery instead.
If you only set
layouts:
- "1/1"
- "1/3, 1/3, 1/3"
You will be able to pick just 1 column as well as the thirds you have already. You can set as many variations as you wish. See here Layout | Kirby CMS
Thank you for your answer ! it worked when i changed the name to gallery (there was indeed an error when named images). But now, how should I style the grid, columns, and block classes ? I donât understand how they should work together.
Also, what i meant by "one row/layout) is that :
I wish that the âaddâ button werenât available. Is that possible ? Because i want that if the client chose 3 columns layout, they only use one layout, and they donât change to 2 columns, so the grid is never broken.
I wonder if the layout field is the right choice for your purpose. Maybe better use a files field in card layout? And no, you cannot limit the number of layouts nor the number of blocks inside the layout.
Your frontend CSS is up to you, Kirby doesnât do that for you. CSS has different ways to create a grid (CSS grid, flexbox etc.).
The thing is Iâd like to mix pictures that i upload and videos that I embed, so i turned to layout, but would you say files is better ? can I add filedset (image and video) to a files field ? i tried previously but couldnât manage that (but my yml was probably not indented correctly, iâm very beginner).
and for the css part, i thought something particular was expected for the layout to work (and especially the masonry effect). But i guess iâll try with this maybe : CSS Grid Layout Module Level 3.
i wanted to avoid importing the masonry library.