0

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!

3

1 Answer 1

1

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());
8
  • Hello, can you explain where should I put that code line? Jul 20, 2019 at 19:39
  • It works now, but in the checkout now it sends me this message : {"success":"You added Donation to your shopping cart."} and does not redirects to checkout, the thing is that this module uses the same template for different areas. The same template is in Checkout, Home page and side bar of product catalog page. Do you know if it would work if I create a separated template for the checkout? Greetings! Jul 20, 2019 at 19:51
  • As i see in the code there are only methods that overload the page (only the one on which they are now) after adding to the product in the basket, to add a redirect from all the places you need to make changes to the code. 1. in method \Experius\DonationProduct\Block\Donation\ListProduct::getProductCollection need add this code $this->setAjaxRefreshOnSuccess(true); Jul 21, 2019 at 5:51
  • Also need will add correct (correct it mean what you need) redirect to method /Experius/DonationProduct/view/frontend/web/js/view/donation.js::InitAjaxCart after success function. for example window.location.replace(url.build('checkout/)); instead location.reload(); on donation.js Jul 21, 2019 at 6:05
  • And change my preview fix return str_replace('\\', '-', parent::getNameInLayout()); to return str_replace(['\\', '.'], '-', parent::getNameInLayout()) Jul 21, 2019 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.