New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Dynamic Zone inside component #5798
Comments
Hello, I see you are wanting to ask a question that is not really a bug report or a feature request, questions should be directed to the following places per the README.md: For now I will mark this issue as closed, we try to keep Github clean and only for bug reports and feature requests unless there is a technical discussion that needs to happen before an RFC needs to be created. However in all 3 cases there are templates to be followed. If you have questions or believe this was closed in error do feel free to reply. |
@wac2007 for UI reasons we have limited the number of nested components to one. It means that you cannot create a component inside another component which is already embedded into another one. |
Even if you add dynamic zone inside component - it just doesn't seem to work. Not in admin nor in API. In admin only input type text gets rendered. And in GQL mutation is created - it cannot be mutated - it won't pass validation. So i would say that having dynamic zone in component is not possible for now at all. EDIT: API mutation works as expected, that means dynamic zone inside component is indeed possible. I will elaborate on my GQL mutation to validate correct implementation. |
can we add dynamic zone also inside a component through backend? |
Any hints on how you got this working? |
Yeah me too. Would be great with a solution to this, as I really need 1 level of nested dynamic zones for my current project. |
Does someone find a solution about this problem ? I see that someone solve the problem on a forked project 5 days ago. |
Enabling the usage of a dynamic zone inside a component is not a feature we want to enable in Strapi. |
@soupette do you know if there is any plan to implement what @alexandrebodin proposed a while ago in this ticket: #5124 ? |
Which solution are you referring to in the issue? The one that would allow creating an entry from another entry? |
Yes, that't the one.
|
For the moment, we don't plan on adding this feature to the CM we are currently actively working on other features like internationalisation and then the V4. |
Hi @soupette, first of all keep the good work, however I need to mention this is a real showstopper for us / our company to adopt Strapi as a headless CMS, we simply can't build a component system on our FEs that mirrors what we have on our CMS, kind of what storyblok is doing (https://www.storyblok.com/). @benderillo we will borrow your fork and see if we can still continue with Strapi. |
@ValterSantosMatos keep in mind that you still need to add the DZ in json file first. The change I made on my fork is to make DZ work in the Admin UI after it has been added in the json file. Keep in mind also, that the change was quick and I have not spent enough time investigating if I accidentally broke something else. |
I am also looking for this feature. |
Could you all share more details with us about the use case of having a DZ into a component? Feel free to share your content-type structure, I would like to know more about why there is no alternative in terms of content structure. |
@Aurelsicoko I initially wanted it so that I can have a user-friendly content authoring experience for Online Course creation with Strapi content manager plugin. A An Educator needs to be able to open an Editor for new Course(type entry), type in a title, pick a thumbnail, and some other info. And when inside a Chapter editor widget, the educator would click another visual signifier to add a As you can see, this workflow currently impossible in Strapi when you go with normal relational types. But doable with the components once you allow DZ in the component (this is needed for picking a type of the component to insert as a Lesson). |
This issue has been mentioned on Strapi Community Forum. There might be relevant details there: https://forum.strapi.io/t/add-entries-to-multiple-related-collections-in-one-view/2891/2 |
@benderillo Thank you for the explanations! As you mentioned, it isn't a content structure limitation, in your use case, everything is possible. However, the content editing experience is bad because you have to move from the Course, then Chapter, then Lesson edit views to write and build an entire course. For example, a possible solution would be to allow you to create a very advanced and custom layout for the Edit view of a Course. I would love to have more use cases like this one to ensure it's our role as a CMS to handle such as specific use cases or is it on your side to develop a custom view by yourself to be able to contribute this way. |
I have the following use case for which I was planning to use repeatable components with dynamic zones: I have a single type for my home page. On this home page, I want the user to be able to add as many sections as they want. Each section can have a title and some content. The content would be a collection of items that can be either some rich text or a CTA. So I made a RichText component with a rich text field and a CTA component with label and URL fields. I then made a Section component with a title field and I was planning to use a Dynamic Zone for the content field so the user can choose between RichText or CTA for each part of the content. I think I can use collection types and relations for that. But it leads to very poor content editing experience for my users as they will have to write each content part isolated, then add relations in the good order, without any context. |
@drazik Your use case makes sense! You could also create a Section component with two fields (title, content) and put it within a giant dynamic zone to divide it per section. I know that visually speaking it could make the contributing experience harder but from a content structure perspective it's the same. FYI, I've shared your use case with the team as it's the first time it would make sense to have a DZ > Component > DZ (Page > Section > Content blocks). |
If I understand your proposition correctly, it doesn't exactly sound the same as my use case. I want a section to have a single title and and collection of "content parts". If I create a Section component with title and content fields and then put it in a dynamic zone, I will get a collection of Sections. Which I would also get if I use a repeatable Section component 🤔 . |
I second this; this is how I build all my CMS websites. In my case, I have a layout that uses a vertical page flow where the top-level component in a Page is always a Section. This gives the user a selection of options (such as the section heading, icon, anchor link, background, fluid/fixed width, vertical space etc) that, if added to each component individually, would really clutter up the individual component options (think of all those options unnecessarily added to a rich-text component where you only need a richtext field). |
I frequently run into annoyances where I need a DZ inside a component. For example, I tend to model content sections so that clients can use Strapi as a CMS, and needed to build a "Popular products in [multiple store fronts]" section. The storefronts had separate collections for the products they offered (because of unique suppliers), and thus I wanted a DZ wherein the component Featured Products has a DZ with multiple optional Relational Fields for different content types. Another recent example is: I was building a main menu single-type with a dynamic zone filled with menu components for easy client use. The Menu DZ had components such as "External link" "Internal Link", "Dropdown submenu" (here I'd like a sub DZ with new options for internal link (relational), external link, etc. I wish internal link and external link could be combined, but I cant have nested dynamic zones so I need to duplicate functionality since I cant nest optional relational content. To make it worse, I'll have to make duplicates of internal link and external link components if I want to add other content types other than generic pages, such as links to articles in the main menu, or store fronts. Strapi really needs DZ inside component functionality. |
It really is a show stopper because it's such a common usecase to nest components. It makes strapi useless. |
Another use case: Why not just have multiple dynamic zones for every combination of lockups? Here are just some potential components that could be used as a column:
To do even just 2 column components for the above is 25, or with some adjustments 10 (using repeaters, and a ltr/rtl field. However, if you want 3 columns, it quickly gets up to 625 combinations, or again with some tweaking 70, or getting really hacky with a bunch of repeaters and 'order' fields maybe 5, however, if you're using Graph QL and you never use 1 of those 5 lockups, the frontend won't develop or build. Worth noting in this example it might not even require DZ -> Component -> DZ and instead could be Repeater -> DZ |
@liamb13 I did that very often using ACF with Wordpress. I'm looking workarounds to get this running. I'm eager on seeing this feature released, because Strapi has a lot of capacities otherwise.. |
While I understand I’m not adding much more to prior discussions. Can I quick state, seeing that email notification has given me excitement and appreciation for the Strapi team. While a feature we’ve all asked for for a little while. Knowing it’s back in discussions brings me joy, we may sometime soon see this feature built into the UI. It’s an amazing community and this drive will surely bring more users back to the Strapi ecosystem. |
@derrickmehaffy Where we can follow the status of this? |
The only place is here, at the moment I have not seen a confirmation from our product team that we will do this. It's still being considered at this time. |
https://portal.productboard.com/strapi/1-roadmap/tabs/2-under-consideration I've seen this and it could be a good alternative to make the product team listen to this feature request. |
The product board isnt entirely up to date, but during StrapiConf we will be announcing our new public roadmap and the public portal that will allow every to suggest, comment (publicly), and vote on feature requests, enhancements, ect. The product team is well aware of this request and it's sister one about nested components. |
Sorry if I appear somewhat redundant and rude, but as people have said it's a big block for a lot of people using Strapi as the main CMS, i.e. I'm currently using it, but currently searching for an alternative to solve this problem, a lot of people are ready to help here, including me, but we are almost lost in this discussion that takes more than 2 years now. Please let us know, how we can push the product team to listen and ask this request, as this doesn't seem to be too complicated at all, and also should be prioritized as many users are cogitating to change their CMS tool away from Strapi due to this limitation. |
Hey, did you find a good alternative to Strapi with this feature? |
@Fabioni My last response to this got marked as off topic so I suspect they'll bury this one too 😆 but take a look at PayloadCMS We're sticking with Wagtail for the time being. |
Yeah I take a look, right now I'm still waiting for Strapi team to consider and implement a fix to this limitation as it will take less effort on our side here, but honestly as long it's not implemented we are moving away from Strapi we know that every change takes time, but c'mon 2 years, people saying this is a big limitation and being ignored, that's not healthy for a tool like Strapi. |
Also tried to push Strapi for our client but this limitation made them decide against it. Is there any news or workarounds? |
No news yet, I'm following currently and sadly it's not a top priority on the team board, even after a lot of people ask for this. |
I needed this on my current project. We started on Wagtail which supports nesting with its StreamField and Blocks, which are analogous to DynamicZones and Components. I had some issues with Wagtail. It doesn't support GraphQL out of the box and implementing it requires writing a lot of boilerplate. It also doesn't treat SVGs as images, bu as documents with a separate media browser. Strapi totally won on those fronts and the overall look and feel and UX. The only reason we didn't choose it was because strapi's inability to implement nested dynamic zones. In our component hierarchy, we define 3 types of components
The rules for our component hierarch design are as follows. For our use cases we don't need infinite recursion, just a few tiers are are perfectly happy with limitations that prevent infinite recursion. This is level of layout control is an essential need of our editorial teams. We weren't able to achieve it with Strapi at this juncture because nested dynamic zones are not possible at all. |
@dopry we're planning on using https://github.com/GrappleGQL/wagtail-grapple and in our initial testing it's been great, did you try that package? |
Yes, but you need to explicitly specify which fields you want to expose to graphql and implement resolvers for tcustom blocks you develop. It's a lot of boilerplate. Strapi is far easier in this regard. There are significantly fewer development steps to expose a component to graphql with Strapi. Strapi is also written in react so we are able to reuse our react component library in the strapi admin to build inline previews. Overall tjoe enables a better editorial ux than you get with Wagtail. Wagtail has a react admin in the works, but it won't be released until at least August. |
Thank you all for your comments. The topic is currently being discussed within the product team. Given our time and resources available, this issue will not be addressed before the second part of the year but we have it in mind. |
Guys that need this, anyone want to pair with me to make it happen in a fork? |
https://github.com/benderillo/strapi/pull/1/files ? This feature critical for us. Use case is to have Layout category with components, for example 6x6, with left and right properties both Dynamic zone - so content editor could decide to put different components side-by-side. Or section component with Background (Media) and Components (Dynamic Zone) - so they can group together some components in same background. So you could have Collection/single type => (DynamicZone) Layout / 6x6 component => (Dynamic Zone) Section / Base Section component => (Dynamic Zone) Gallery Component or any other component |
@wesleyguirra @Warxcell you can look at the PR I made in the fork for Strapi v3 ages ago. Unfortunately, I cannot lend a hand on this one as I have no capacity at the moment. |
Closing this in favor of: https://feedback.strapi.io/customization/p/dynamic-zone-in-components We are considering this, if those who have commented are still interested in this can you please go log your vote on the feedback page (we are trying to clean up issues so we can fix bugs a little faster 😃 ) |
Hello people,
I'm trying to add a Dynamic Zone inside a repeatable component but this option doesn't show inside a custom component.
Here what i'm trying to accomplish:
The options:
There's a way to "unlock" this feature or this isn't possible yet?
The text was updated successfully, but these errors were encountered: