Magento 2 include template with form in CMS Block
Вопрос
I have been struggling trying to put a template functionally working inside a CMS Block. When I put this code inside my CMS block the template is correctly implemented
{{block class="Experius\DonationProduct\Block\Donation\ListProduct" name="cms.donation.list" template="Experius_DonationProduct::donation.phtml"}}
However, the template has a pop up window that comes up when you click a button, and that pop up has a form. The problem is that the pop-up window does not come up when it's in the CMS block, it's like if JS functions were not working.
The template is located in app/design/frontend/Vendor/Theme/Experius_DonationProduct/templates/donation.phtml
its override from the original module.
What can I do?
Thank you and greetings!
Решение
As i see a problem with cms block associated with the method \Experius\DonationProduct\Block\Donation\ListProduct::getIdentifier
.
The problem is that when we get the block name in cms, we get a name that contains an element "\" that can not be properly processed. Please try change method getIdentifier for that
return str_replace('\\', '-', parent::getNameInLayout());