System Information
- Strapi Version: 4.0.4
- Operating System: macOs Monterey
- Database: sqlite
- Node Version: 16.13.1
- NPM Version: 8.1.2
- Yarn Version: 1.22.17
Hello everyone,
I made a collection with a dynamic zone with components (blocks) inside it, and sometimes components nested inside my blocks. When I query the collection the api show the first level blocks but not components which are nested inside, nor images. I understand I have to populate my blocks, but I have no idea on how to achieve that.
Content architecture :
Collection
-----Dynamic zone
-------Blocks
----------Block
----------Block
---------------Nested Block <----- trying to populate that
-----------Block
-----------Block
…
Here is my controller (I query my collections by slug) :
"use strict";
/**
* study controller
*/
const { createCoreController } = require("@strapi/strapi").factories;
// module.exports = createCoreController('api::study.study');
module.exports = createCoreController("api::study.study", ({ strapi }) => ({
async findOne(ctx) {
const { id: Slug } = ctx.params;
const { query } = ctx;
if (!query.filters) query.filters = {};
query.filters.Slug = { $eq: Slug };
const entity = await strapi.service("api::study.study").find(ctx.query);
const { results } = await this.sanitizeOutput(entity);
return this.transformResponse(results[0]);
},
}));
Here is my endpoint where my first level blocks are displayed, but for exemple, the block blocks.image-wide should have another component inside it and a media
"data": {
"id": 1,
"attributes": {
"heading": "Notre dernière publication",
"description": "Regards croisés entre les épargnants et leurs conseillers financiers.",
"primaryButton": true,
"primaryButtonLabel": "Consulter l'étude",
"secondaryButton": true,
"secondaryButtonLabel": "Résultat de l'étude",
"createdAt": "2021-12-23T10:23:04.396Z",
"updatedAt": "2022-01-24T22:15:11.845Z",
"publishedAt": "2021-12-23T10:23:14.197Z",
"slug": "fonds-en-euros-quelle-place-demain-dans-l-epargne-des-francais-h1",
"introduction": "Fidelity International a fait confiance à Insight AM pour mener une étude sous forme de regards croisés auprès des épargnants français (plus de 1000 épargnants interrogés) et des distributeurs (plus de 400 Conseillers en Gestion de Patrimoine et Banques Privées consultés) sur leurs perceptions de la baisse du rendement du Fonds Euros.",
"theme": "EtudesReferencementThematique",
"title": "PER, quelle place demain dans l’épargne des Français ?",
"cover": {
"data": {
"id": 3,
"attributes": {
"name": "egor-vikhrev-Z-5i0RVukdU-unsplash.png",
"alternativeText": "mon image",
"caption": "mon image",
"width": 1287,
"height": 857,
"formats": {
"thumbnail": {
"name": "thumbnail_egor-vikhrev-Z-5i0RVukdU-unsplash.png",
"hash": "thumbnail_egor_vikhrev_Z_5i0_R_Vukd_U_unsplash_8755a365d8",
"ext": ".png",
"mime": "image/png",
"width": 234,
"height": 156,
"size": 76.12,
"path": null,
"url": "/uploads/thumbnail_egor_vikhrev_Z_5i0_R_Vukd_U_unsplash_8755a365d8.png"
},
"large": {
"name": "large_egor-vikhrev-Z-5i0RVukdU-unsplash.png",
"hash": "large_egor_vikhrev_Z_5i0_R_Vukd_U_unsplash_8755a365d8",
"ext": ".png",
"mime": "image/png",
"width": 1000,
"height": 666,
"size": 1377.96,
"path": null,
"url": "/uploads/large_egor_vikhrev_Z_5i0_R_Vukd_U_unsplash_8755a365d8.png"
},
"medium": {
"name": "medium_egor-vikhrev-Z-5i0RVukdU-unsplash.png",
"hash": "medium_egor_vikhrev_Z_5i0_R_Vukd_U_unsplash_8755a365d8",
"ext": ".png",
"mime": "image/png",
"width": 750,
"height": 499,
"size": 776.22,
"path": null,
"url": "/uploads/medium_egor_vikhrev_Z_5i0_R_Vukd_U_unsplash_8755a365d8.png"
},
"small": {
"name": "small_egor-vikhrev-Z-5i0RVukdU-unsplash.png",
"hash": "small_egor_vikhrev_Z_5i0_R_Vukd_U_unsplash_8755a365d8",
"ext": ".png",
"mime": "image/png",
"width": 500,
"height": 333,
"size": 344.24,
"path": null,
"url": "/uploads/small_egor_vikhrev_Z_5i0_R_Vukd_U_unsplash_8755a365d8.png"
}
},
"hash": "egor_vikhrev_Z_5i0_R_Vukd_U_unsplash_8755a365d8",
"ext": ".png",
"mime": "image/png",
"size": 2092.91,
"url": "/uploads/egor_vikhrev_Z_5i0_R_Vukd_U_unsplash_8755a365d8.png",
"previewUrl": null,
"provider": "local",
"provider_metadata": null,
"createdAt": "2021-12-28T14:43:19.734Z",
"updatedAt": "2022-01-24T21:57:28.624Z"
}
}
},
"blocks": [
{
"id": 1,
"__component": "blocks.title-h2",
"title": "Détail de l’étude (H2)"
},
{
"id": 2,
"__component": "blocks.title-h3",
"title": "L’environnement économique (H3)"
},
{
"id": 1,
"__component": "blocks.list"
},
{
"id": 1,
"__component": "blocks.text",
"text": "Si le fonds en euros reste le placement privilégié des épargnants français dans le cadre de contrats d’assurance vie, dont les encours s’élevaient à 1 741 milliards d’euros (fin mars 2020), la baisse de ses rendements a connu une sensible accélération. Alors que les souscripteurs en assurance-vie se voient désormais davantage sollicités pour mobiliser leur poche UC, en vue de compenser la baisse des rendements, nous avons souhaité les interroger, ainsi que leurs distributeurs afin de recueillir leurs perceptions et leurs attentes.\n\nN’hésitez pas à consulter les résultats de l’enquête et principaux enseignements de cette étude en la téléchargeant à compter du 09 juin 2020 !"
},
{
"id": 2,
"__component": "blocks.title-h2",
"title": "Image panoramique (H2)"
},
{
"id": 1,
"__component": "blocks.image-wide"
},
Thank you for your answers