I have a content type "Slider" which uses an Entity reference revisions field named "Slides" to save reference to various paragraphs that are then displayed on the frontend as a hero slider.
Everything works fine but now we have received a request of filtering out the slides by a show/hide boolean flag in the slide paragraph. Adding a boolean field to each such paragraph is straightforward but how do I filter those paragraphs based on it? I'm assuming a Drupal hook that allows a function to filter out the referenced entities by some arbitrary criterion but I've been unable to find it.
I understand that this question relates to a 3rd party module but it is quite possible that a core Drupal hook could be used in this context.
Any help will be greatly appreciated.
Thanks.
3rd party module
are you using?hook_paragraph_access()
looks like the hook I have been search for :D I will try it out and post the results.hook_paragraph_access()
which implementshook_ENTITY_TYPE_access()
(api.drupal.org/api/drupal/…) worked out nicely for limiting access to paragraph entities based on their custom field but my field renderer still kept rendering empty containers for inaccessible paragraphs. The field formatter is part of yet another 3rd party module so I'm thinking it has to with that module's code. A perfect solution otherwise.