Output a specific page's datas from a "page builder" structure field

i just wanted to know the code to display the first image in case of i couldn’t manage what i wanted, i wanted to store it, but i’ll go with the full list of all images if i can do that.

Also i just want to display categories of the specific project not all categories. Cant make it work i really get confused easily.

The code I posted above only gets all categories per project, not all categories of all projects.

Ok, it’s certain im doing something wrong with your code; it doesnt work:

<?= $categories = $p->category()->split(',');

You can’t use an echo statement here! Should be

<?php $categories = $p->category()->split(',');  ?>

But I’d move this variable definition piece of code further up, after where you check if $p is true.

I’d recommend you get up to speed with some PHP basics, will make your life with Kirby a lot easier.

The magic is what i have been able to do with kirby and its doc and its community (mainly you) without knowing shit about php! ill definitely take the time to learn the basics!

It’s working but when there is several category for a project there is no separator, how do i add it?

I already said above, you either have to echo the separator conditionally, or better: use CSS to add the separator using an afterpseudo-element (put each category in a span with a classname) instead of echoing it in the template.

If you must have the comma in. the template, you can also do this:

<?php echo implode(', ', array_intersect_key($categoryMap, array_flip($categories))); ?

Ok, so, i wrapped project infos into some ul and li, added a separator for all element that aren’t last child of this li in the pseudo element after in the css. Everything is working fine, here is my code after other changes (switches to display or not infos):

I choose to keep the page picture and i will try to follow your advices above to have a list of all pictures.

https://pastebin.com/sHWzmfgF

one last thing, for example, place is not a mandatory information in the project page, therefore, if i choose to display place in the showcase fields but there is no place info in the project text file, it only show a " ,". What bit of code should i add to check if the info exist and doesn’t display anything if it doesn’t?

https://getkirby.com/docs/cheatsheet/field-methods/isEmpty