backdrop-contrib / paragraphs

Paragraphs module to control your content flow
https://backdropcms.org/project/paragraphs
GNU General Public License v2.0
5 stars 11 forks source link

Use the correct preprocess hook for paragraph item #111

Closed argiepiano closed 2 years ago

argiepiano commented 2 years ago

Fixes #110

In order for the fix to work you MUST also apply #109

laryn commented 2 years ago

Thank you @argiepiano -- much appreciated all the digging on this one. I'll just have to make a prominent warning about the other hook no longer working at all when I release this. Your work does make sense!

argiepiano commented 2 years ago

I'll just have to make a prominent warning about the other hook no longer working at all when I release this. Your work does make sense!

Eventually we may want to take a look at how Entity Plus handles the theming of custom entities such as Paragraphs.

Another option while we look into how entity plus handles entity viewing, would have been to implement hook_entity_plus_view and change the theme right there. I believe that would have allowed us to use the paragraph_item preprocess function.

argiepiano commented 2 years ago

Yet a third way to avoid using hook_preprocess_entity_plus and use preprocess_paragraphs_item would have been for Paragraphs to extend class EntityPlusController to implement buildContent, and specify the theme to be used to display Paragraphs. I noticed that Paragraphs doesn't extend EntityPlusController at all, and therefore relies on its method to build content and theme the paragraph entity

laryn commented 2 years ago

@argiepiano Ah, interesting. That third way sounds like a good option actually -- that would allow things to function the way many people assume they should, right?

argiepiano commented 2 years ago

@argiepiano Ah, interesting. That third way sounds like a good option actually -- that would allow things to function the way many people assume they should, right?

Right. I can take a stab at that later today and test. It shouldn't be too involved

laryn commented 2 years ago

That sounds great. I was about to start reworking Classy Paragraphs (since it uses hook_preprocess_paragraphs_item but if this is achievable in the short term I'll pause on that. (Would be nice not to have to tell everyone to rewrite custom functions they may be using on the next update, too).

argiepiano commented 2 years ago

@laryn I did not have a chance to try this last night, but I'll try tonight. Got entangled with Entity Plus, cleaning up the taxonomy term and vocabulary wrappers!

laryn commented 2 years ago

@argiepiano Sounds tangly!