0

I override content.html using /app/design/frontend/Altius2/Jasani/Magento_Checkout/web/template/minicart/content.html

When I change stuff in this it changes but I can't use PHP because it's an HTML file. So I created a custom phtml and added the code below.

1.Created PHTML

app/design/frontend/{Vendor}/{theme}/Magento_Checkout/templates/my-custom.phtml

<?= /* @escapeNotVerified */ __('My html is loaded') ?>
<h3>successfully !</h3>

2.instantiate our custom phtml:

app/code/Module/Vendor/view/frontend/templates/cart.phtml
<?php $myphtml = $block->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Magento_Checkout::my-custom.phtml")->toHtml(); ?>

<script type="text/javascript">
    var my_phtml = <?php echo json_encode($myphtml); ?>;
</script>

3.Added to html

./app/design/frontend/Altius2/Jasani/Magento_Checkout/web/template/minicart/content.html

<div id="my-dialog-id" title="Information" data-bind="html:my_phtml" />

I see the changes only in that cart.phtml 's controller but not in all pages.

I need to completely override the content.html with php code. Thanks in advanced.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.