Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem:
If i have a layout with 2 columns, i can only restrict paragraphs for the whole layout. If a paragraph is only suitable for the left column, I can't restrict the editor to only allow the paragraph in the left column.
Proposed resolution:
Additionally to restrict paragraphs per layout, it is also possible to define for each column which paragraphs are allowed.
Comments
Comment #2
dermarioMarking this as critical, as this is the main purpose of this module.
Comment #3
InaW CreditAttribution: InaW at Unic commentedComment #4
saschaeggiHuge +1
Comment #5
waluigi CreditAttribution: waluigi at Unic commentedThanks for the suggestion, that totally makes sense to me as well. I created a patch for this, I'd appreciate any testing :-)
Comment #6
saschaeggi@waluigi applied the patch and did some testing
Looks good so far, but when I want to add a paragraph it doesn't show up at all.
Also I think #3087079: Allow all paragraph types if none are selected is important as well.
Comment #7
saschaeggiAlso we might want to make sure that it still works with this patch from entity_reference_layout #3070005-11: Implement a nicer solution to element selection applied.
Comment #8
waluigi CreditAttribution: waluigi at Unic commentedThanks for the feedback, @saschaeggi.
The problem was that they were moved to "disabled items" directly because it did not fetch the allowed paragraphs correctly for the target region. Also one could not drag and drop it into other regions for the same reason. I was not yet able to fix the whole problem, however the drag and drop is working now.
Newly added paragraphs will still be appended to the disabled items wrapper. I'm still working on a solution for that.
Comment #9
waluigi CreditAttribution: waluigi at Unic commentedI was able to fix it. The problem was a reference to a wrong parent.
Thanks for any feedback!
Comment #10
waluigi CreditAttribution: waluigi at Unic commentedComment #11
dermarioI reviewed the PHP part of this patch and it looks awesome already. These are my findings:
I wonder if we could store
$this->getSettings()['restrictions'][$layout]
in a variable to make the following code more readable/meaningful.This comment is obsolete.
I think entity.manager gets deprecated in D9 we should avoid using it.
The new service should use dependency injection in favor of creating the service on the fly.
Comment #12
waluigi CreditAttribution: waluigi at Unic commentedThanks for the feedback @dermario. I implemented your suggestions. What do you think now?
Comment #13
waluigi CreditAttribution: waluigi at Unic commentedSince my codesniffer is currently not working properly I missed some spaces. Here is the new patch.
Comment #14
dermarioThis looks fine for me now. We could fix these while committing the patch.
This could be single quotes for consistency reasons.
Comment #16
waluigi CreditAttribution: waluigi at Unic commentedThanks to all for the support! :)
Comment #17
waluigi CreditAttribution: waluigi at Unic commented