Nested data for dynamic zone components

Hello,

I have a problem with missing nested data in a dynamic zone.

I had a similar problem before in a case without a dynamic zone. With help of Second level of nested relationship not available in response and Simple nested array issue I found a solution for this.

Now I’m trying to do the same for with a dynamic zone, but this will not work.

I have the following structure:

artcicle:
title
slug
article_category (Relation)
contents (dynamic zone with two other components)

One of these contents-components has a repeatable links-components. And this link has a relation to article.

So here is an example of the structure for a single article:

{
    "id": 26,
    "title": "FAQ-Artikel",
    "slug": "faq-artikel",
    "content": null,
    "article_category": {
        "id": 3,
        "title": "Versicherungstipps",
        "slug": "versicherungstipps",
        "description": null,
        "icon": null,
        "active": true,
        "created_at": "2021-02-03T14:20:32.454Z",
        "updated_at": "2021-03-09T13:55:00.851Z",
        "published_at": "2021-02-03T14:20:32.454Z",
        "views": "3",
        "scope": "promotionbasis",
        "meta": {
            "id": 2,
            "title": "Versicherungstipps Title",
            "description": "Versicherungstipps Description",
            "keywords": null,
            "prevent_indexing": null,
            "share_image": null
        },
        "seo_content_config": null
    },
    "teasered": false,
    "relation_tags": null,
    "views": "34",
    "published_at": "2021-06-30T19:40:12.543Z",
    "created_at": "2021-06-30T19:40:08.359Z",
    "updated_at": "2021-07-02T11:39:03.050Z",
    "scope": "promotionbasis",
    "intro": "Intro-Text...",
    "searchtext": null,
    "contents": [
        {
            "__component": "elements.text-image",
            "id": 7,
            "content": "Ich bin ein Einleitungsinhalt...",
            "float_image": null,
            "image": null
        },
        {
            "__component": "elements.faq-card",
            "id": 11,
            "question": "Frage 1",
            "answer": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.\n\nCum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.\n\nNulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.\n\nIn enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus.\n\nVivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.\n\nAliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet.\n\nEtiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus.\n\nMaecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem.\n\nMaecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,",
            "links": []
        },
        {
            "__component": "elements.faq-card",
            "id": 12,
            "question": "Frage 2",
            "answer": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.\n\nCum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.\n\nNulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.\n\nIn enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus.\n\nVivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.\n\nAliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet.\n\nEtiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus.\n\nMaecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem.\n\nMaecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,",
            "links": [
                {
                    "id": 75,
                    "Text": null,
                    "Url": null,
                    "Target": null,
                    "Title": null,
                    "Icon": null,
                    "text": "Link 1 Artikel",
                    "icon": null,
                    "class": null,
                    "href": null,
                    "target": null,
                    "route": null,
                    "page": null,
                    "article": {
                        "id": 17,
                        "title": "Noch ein Artikel",
                        "slug": "noch-ein-artikel",
                        "content": "g hjg kg kghj g",
                        "article_category": 1,
                        "teasered": false,
                        "relation_tags": null,
                        "views": "17",
                        "published_at": "2021-02-05T14:22:31.569Z",
                        "created_at": "2021-02-05T13:57:15.493Z",
                        "updated_at": "2021-07-02T03:50:56.122Z",
                        "scope": "promotionbasis",
                        "intro": "Einleitung, Intro-Text",
                        "searchtext": null,
                        "card_image": null,
                        "cover_image": []
                    },
                    "activity": null,
                    "city": null,
                    "title": null
                },
                {
                    "id": 76,
                    "Text": null,
                    "Url": null,
                    "Target": null,
                    "Title": null,
                    "Icon": null,
                    "text": "Link 2 Extern",
                    "icon": null,
                    "class": null,
                    "href": "https://ipark.de",
                    "target": "_blank",
                    "route": null,
                    "page": null,
                    "article": null,
                    "activity": null,
                    "city": null,
                    "title": null
                },
                {
                    "id": 77,
                    "Text": null,
                    "Url": null,
                    "Target": null,
                    "Title": null,
                    "Icon": null,
                    "text": "Link 3 Page",
                    "icon": null,
                    "class": null,
                    "href": null,
                    "target": null,
                    "route": null,
                    "page": {
                        "id": 17,
                        "InternalTitle": "Wiki-Übersicht",
                        "slug": "wikis",
                        "InternalDescription": null,
                        "Layout": null,
                        "Active": null,
                        "created_at": "2021-04-29T10:56:57.754Z",
                        "updated_at": "2021-07-01T13:00:17.574Z",
                        "published_at": "2021-04-29T10:57:00.587Z",
                        "views": "40",
                        "scope": "promotionbasis",
                        "show_seo_content": null
                    },
                    "article": null,
                    "activity": null,
                    "city": null,
                    "title": null
                }
            ]
        }
    ],
    "meta": {
        "id": 54,
        "title": null,
        "description": null,
        "keywords": null,
        "prevent_indexing": false,
        "share_image": null
    },
    "seo_content_config": null,
    "card_image": null,
    "cover_image": [],
    "related_articles": [],
    "article_tags": []
}

In the faq-card-data I miss the information about the article category. I need this for routing, I need the category-slug to build the route.

I tried to change the services-file at /article/services/article.js like this:

const _ = require('lodash');

module.exports = {
  /**
   * Promise to fetch all records
   *
   * @return {Promise}
   */
  async find(params, populate) {
    const results = await strapi.query('article').find(params, [
        'article_category',
        'contents',
        'contents.links',
        'contents.links.article',
        'contents.links.article.article_category',
      ]
    );

    return results;
  },
};

But this is not working, maybe because the level of the faq-component is missing? But how can I add it?

Sorry for this extensive question with the code example.

Hope someone can help me with this!

Best regards,

Timo

1 Like

Hello, I have the same problem, could you solve it?

I have the same problem. Does anyone have a solution offer for this? @iparker @Carlos_Osvaldo_Chao

add me to the list of people curious about the solution :sweat_smile: