Closed (fixed)
Project:
Ajax Block
Version:
3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Oct 2022 at 20:46 UTC
Updated:
4 Mar 2023 at 21:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
geoanders commentedComment #3
geoanders commented@MacSim
Looks like Twig Tweak doesn't call alter hooks which happen in the Ajax Block module. Seems like the module renders blocks differently.
See issue here: https://www.drupal.org/project/twig_tweak/issues/3215911
I have not tested out the patch, but seems like Ajax Block and Twig Tweak are currently not compatible right now.
Comment #4
geoanders commentedPostponing for now.
Comment #5
macsim commentedAnyway the
AjaxBlockControlleris not handling plugin blocks.If you call
/block/ajax/user_login_form(or another plugin block id), the controller returns an empty response.It might not be the main purpose of the module, but that could be useful if you want to load and display a block from a JS when a user triggers an event on an element.
The
'plugin.manager.block'service is injected but never used except in the constructor to instantiate$this->blockManager = $block_manager;Comment #6
macsim commentedJust in case
drupalBlock()would been able to callhook_block_view_alter()and in order to reply to #5 we might do something like what's provided in this patch.Comment #7
macsim commentedComment #8
geoanders commented@MacSim
Thanks for the patch. Will adjust a bit, but falling back to the block plugin works for me. Have a few adjustments and cleanup to do in the controller anyways due to other tickets/issues. Will get this added in when I get some time.
Comment #9
geoanders commentedComment #10
geoanders commentedComment #15
geoanders commented@MacSim
Applying the twig_tweak patch (below) related to this issue and using the latest Ajax block 3.x dev branch, now allows the drupal_block twig function to work better with Ajax block.
Let me know if this works on your end.
Twig Tweak patch:
https://www.drupal.org/files/issues/2021-05-26/twig_tweak-block-view-alt...
Comment #16
macsim commentedHey @geoanders
Sorry I've been sick last week.
It's good for me, I can load a block using the twig teak technique + the patch provided in #15.
Thus being said, if the block I load have a form in it with ajax behaviors on some form fields, those behaviors are broken.
The form validator is broken as well - it is triggered but the errors won't show up - I don't know if it is because of the ajax behavior on the submit button or not and I am not sure it would be related to the current issue.
Comment #17
geoanders commented@MacSim
No worries and hope you feel better! Thanks for confirming.
I wonder if it's just a matter of attaching behaviours after AJAX call with the following code on success:
Comment #18
capellicI've tested this patch and it works well. Thanks!
Comment #19
geoanders commented