How to contextually limit paragraphs types in library?

Created on 28 May 2018, about 6 years ago
Updated 22 September 2023, 9 months ago

Status quo (v1.2)

I've got a node with two paragraph fields:
- field_banner
- field_pagebuilder

I've got quite a lot of paragraph types, but basically I can divide them in three groups:
- paragraph types only used in field_banner
- paragraph types only used in field_pagebuilder
- special paragraph types not used in the two fields above

Until version 1.2 I used the field setting "Include the selected below ... (my manual selection of paragraph types)" to limit available paragraph types per parent paragraph field.

E.g. in field_banner, my editors only could add paragraph types "Hero image" and "Hero video". In field_pagebuilder I have dozen other paragraphs like "Text", "Image", "Image gallery", "Google Maps", etc... and those OTOH must not be available as banners.

Adding library feature (v1.3)

I updated to version 1.3 because my editors always wanted to resue paragraphs accross nodes. I still use the default configuration of the Paragraphs library submodule. All paragraph types selectable either in field_banner or in field_pagebuilder are now marked as "Allow adding to library". In the field settings of both, field_banner and field_pagebuilder, I added the "From library" paragraph type to the list of allowed types. The basic functionality is working, I now can promote and reuse paragraphs.

Question: How do I limit available paragraph types in the library per parent field?

The problem is that editors now can bypass the allowed paragraph types for each field using the library feature.
E.g. an editor first creates a hero image paragraph, and promotes it to the library. Then he continues to field_pagebuilder and chooses "Add from library". There he can select the hero image from the library, and could place a hero image anywhere on the page (-builder).

Can this be done by configuration (contextual view filter? entity browser?) or does the library provide a hook for this?

TiA,
Reinhard

✨ Feature request
Status

Active

Version

1.0

Component

Module: Library

Created by

πŸ‡¦πŸ‡ΉAustria hudri Austria

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom sergiur London, UK

    Suggestion in #9 is very useful and it covers our use case (thank you!), though it would still be nice to have a prefiltered entity browser for a more visual experience, especially if the library is extensive. A select will do fine for now though.

    RE #12: I believe the issue is you can add any allowed paragraph type to the library, then you create a paragraph reference field on your node to allow, say, 2 different paragraph types to be referenced + the From library paragraph. Since you are allowing the From library paragraph in your parent field, there is no way to add validation to stop the user from referencing any paragraph type via the From library entity browser. No matter what paragraph type you select from the library, it will let you save it because you're allowing the From library paragraph in the parent field. Not sure what you mean by selecting items of the "wrong" type. Where do you define the wrong type is?

Production build 0.69.0 2024