Hi again! I have a question on something that has been bugging me the las couple of days:
I was just implementing a blueprint for a single project inside a ‘projects’ folder. Everything works fine in the front-end for each project —its a slider implementation where @texnixe gave me a hand the other day —, the thing is I need to have almost all those fields inside the builder so I can insert them in the slider.
Now I am in the need to create a post (thumbnail) gallery where later I plan to use with Isotope filters on. I’ve not been able to get the ‘coverimage’ in the loop, in fact, nothing shows in the projects pages besides its title and text (it’s based on the kirby starterkit projects page).
I’ve tried some solutions that seem similar to my problem with no luck .
Here is my actual blueprint for the single project page, maybe it’s still a mess hahaha, but all the fields work ok, some are not displayed correctly on the panel, but doesn’t matter for now:
title: Single Project
template: single-project
files:true
...
fields:
title:
label: Title
type: text
builder:
label: Sections
type: builder
fieldsets:
coverimage:
label: Imagen Portada
snippet: sections/coverimage
fields:
picture:
label: Imagen
type: image
text:
label: Título Proyecto
type: text
bodytext:
label: Párrafo
snippet: sections/bodytext
fields:
text:
label: Texto
type: textarea
imageBanner:
label: Imagen
snippet: sections/imagebanner
fields:
picture:
label: Imagen
type: image
ficha:
label: Ficha Técnica
snippet: sections/ficha
fields:
architects:
label: Architects
type: text
team:
label: Team
type: text
client:
label: Client
type: text
strengineering:
label: Structural Engineering
type: text
techinspection:
label: Technical Inspection
type: text
structure:
label: Structure
type: text
interiors:
label: Interiors
type: text
photography:
label: Photography
type: text
sitearea:
label: Site Area
type: text
builtarea:
label: Built Area
type: text
completion:
label: Completion
type: text
This is the last snippet I tried, based on this post:
Looking at your blueprint, the image you’re trying to access is the picture field of the coverimage fieldset.
The builder plugin uses fieldsets to differentiate the type of entries. In your case you want to loop through the fieldsets in your $project pages and select only the coverimage fieldset.
Next, the image is selected in the field “picture” inside that fieldset. So you need to adapt your code to select that.
Here’s code I haven’t tested but that should work for your case. Let us know if you hit any roadblocks! For others ending up here looking for guidance on how to use the builder field, the documentation on Github is actually quite comprehensive.
Hi @Thiousi! Thank you for your answer and explanation of it!
I tested the code above, it didn’t work. May I mention, the snippet was located directly in the ‘snippets’ folder and called in a ‘projects.php’ template file as <?php snippet('projects') ?> .
I also just tried moving it inside the sections subfolder (as recommended by the docs) and calling it from the subfolder with no luck either
Can you detail what you had as a result? It’s helpful to explain:
if you turned debugging on
what was the outcome
have you tried copying the code from the snippet directly to your template?
We’re going to find a solution
Note: the expected outcome of the code above is to list all the children of the projects page.
For each children, the title of the page is displayed in a link to the page
Then if the page has a builder field, with a coverimage fieldset, with a valid image selected in the picture field, this image will be displayed (within a link to the project page and the title of the project page as an alt text).
When you say there is nothing after the main text, have you checked the source code to see what exactly gets rendered? Is no part of the whole snippet rendered, not even the ul tags?
Have you put your snippets into the sections subfolder in /templates? Then your code should be like this, i.g. sections instead of projects as the folder name, and also the slash is missing from your code above:
I went several steps back looking for what could be the problem. At the end it was a misconfiguration on the site.php blueprint where it was forcing the default one (Title + Text), just as @texnixe explained in this post many days ago → Bydefault redirected to default template
Since the site blueprint was forcing the content created in the “Projects” page, all the text files were named “default.txt”, so I changed them to their corresponding name and the thumbnails showed up, in this case while testing with the snippet that @Thiousi posted here, since the correct blueprint and template for projects were being applied.
So, the lesson I learned with this issue: Always check the site.php —and the .txt filenames—, especially if you are working with the Kirby starterkit. (I am leaving it posted in case someone gets the same problem in the future).
In the end it’s kind of a rookie mistake, but a setting that many people may ignore.