I've made a custom module, with the ability to print the terms and conditions on a static page. I've achieved this by posting a question on Stack, which answer worked for me: Show terms and conditions on static page
(I've followed to above exactly)
Now, I've created the module with the intention to be reused in other instances of Magento 2(.2.3). So, I've installed the module on a clean installation of Magento 2:
- Enabled developer mode
- Created corresponding vendor folder
- Uploaded the module to the vendor folder
php bin/magento setup:upgrade
php bin/magento setup:di:compile
- created terms and conditions
- enabled the function in the backend (I created a Helper for this)
php bin/magento cache:flush
- Browsed to http://www.mywebshop.com/termsconditions
/termsconditions url loads correctly, so this means the module is working. But somehow, the code which gets the agreement content, returns empty?
This all may sound like a stupid question, but as far as I know, there shouldn't be going something wrong.
array (size=0) empty
Whilst I have created terms and conditions via the admin menu and which show up correctly.
Also the terms and conditions show up in the DB.
Someone who knows what I might have forgotten or what is going wrong?
The code in
<?php /** * @var $block \Magento\CheckoutAgreements\Block\Agreements */ ?> <ol class="agreements items"> <?php var_dump($block->getAgreements()) ?> <?php foreach ($block->getAgreements() as $agreement): ?> <li class="item"> <?php if ($agreement->getIsHtml()):?> <?php /* @escapeNotVerified */ echo $agreement->getContent() ?> <?php else:?> <?php echo nl2br($block->escapeHtml($agreement->getContent())) ?> <?php endif; ?> </li> <?php endforeach ?> </ol>
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <title>Terms and Conditions</title> </head> <body> <referenceBlock name="page.main.title" remove="true" /> <referenceContainer name="content"> <block class="Magento\CheckoutAgreements\Block\Agreements" name="terms_conditions" template="Vendor_TCRender::terms.phtml"/> </referenceContainer> </body> </page>