Configure disallowed paragraphs per content type

Created on 18 August 2023, over 1 year ago
Updated 29 August 2023, over 1 year ago

Problem/Motivation

We switched to Layout Paragraphs Limit after our Drupal 10 update and were previously using Layout Paragraphs Restriction . Layout Paragraphs Restriction allowed for configuration of disallowed paragraph types on a per content type basis.

Proposed resolution

We suggest to add an option to limit different sets of paragraph types available for each content type that do have a Layout Paragraphs field.

Remaining tasks

I'm going to provide a patch for our initial implementation. We don't use Layout Paragraphs Limit for any other entities then nodes. This would be a breaking change for projects that do use Layout Paragraphs Limit for other entity types. I'm not sure how to resolve this issue. There might be a way to enable/disable limits per node in config. Or our patch can be extended so that it'll not only work for content types that have a Layout Paragraphs field but for any entity types that do instead.

Data model changes

This patch adds another top level map content_type to the layout_paragraphs_limit.settings config schema.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany larskleiner

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

Comments & Activities

  • Issue created by @larskleiner
  • 🇭🇺Hungary nagy.balint

    Hi!

    As far as I know it is possible at the field setting of the paragraph field to set which paragraphs types are available.
    Which even works when reusing the field.

    While this module allows to restrict further by setting up which paragraphs types (from the allowed ones) are available in each layout or region of the layout.

    So for now I am not sure we should change the config, as it is already possible to do, unless I'm missing something.

  • 🇭🇺Hungary nagy.balint

    I guess the use case here could be if we would like to limit the layouts differently for each content type.

    So for content type A, and layout X we would like to allow a type, while not allowing it for layout Y,
    but for content type B, and layout X we would not like the allow that type, and lets say allowing it for layout Y.

    Then of course a further layer of config would be necessary, however I'm not sure if that would not make the config a bit too difficult to manage.

  • 🇭🇺Hungary nagy.balint

    I guess for something like this to get into the module,
    we would need a UI that is similar to what is in metatags module for example, where one can create config sets, and either create a global one, or one for a specific content type that takes precedent.

  • 🇩🇪Germany larskleiner

    Thanks for looking into this.

    What you describe in #4 is exactly our use case.

    Good suggestion to extend the UI similar to Metatag's config sets. That approach would allow for any entity type to create subsets from the global config and inherit from it.

    I'll look into how much time I'd be able to put into an extended patch for this approach.

  • 🇦🇹Austria hudri Austria

    I don't think the Metatag schema fully applies here. Metatags are one-per-entity, but Layout paragraphs are fields of entities, and there can be multiple entity reference revision fields on a single bundle. So if we start going this road anyway, maybe we should go straight to field level.

    Currently we have layout > region > ...list of paragraphs
    The patch changes this to bundle > layout > region > ...list of paragraphs
    But I think the proper structure would be the triplet of entity + bundle + field:
    entity_type.bundle.field_name > layout > region > ...list of paragraphs

  • 🇩🇪Germany larskleiner

    I agree it would be good to have the overrides as part of the field config, that's also how it was done in Layout Paragraphs Restriction.

    Attached an updated patch, for now just with a bug fix for the previous patch where the schema changes weren't reflected in the JS validation.

  • 🇩🇪Germany larskleiner

    Another minor update to my patch as the JS validation in #8 did only work on node edit but not on node add forms.

Production build 0.71.5 2024