Question

We are running into an issue where we need to run a little php script within a .html file in Magento 2, namely;

/app/design/frontend/CleverSoft/core/Magento_Checkout/web/template/minicart/content.html

When we have tried adding the ability for html files to run php via the .htaccess, it ends up causing other errors within Magento so it just ends up breaking more things. Namely, using things like;

AddType application/x-httpd-php56 .php .htm .html

or

AddType application/x-httpd-php .html .htm

Are there other alternatives to try to run php within this html file, or is it possible to change this file to .phtml like so many of the others? I would just have to find where it is originally called I assume and change that from .html to .phtml?

Thanks for the insight!

Was it helpful?

Solution

You're asking how to run PHP inside a client-side rendered file which is not feasible. I believe you would need to build this yourself from scratch.

The template is set in vendor/magento/module-checkout/view/frontend/layout/default.xml

<item name="template" xsi:type="string">Magento_Checkout/minicart/content</item>

As you can see there is no file suffix, but even if there was changing this would not help you as UI Component templates are rendered client side so you will not be able to run PHP.

More importantly, why do you need to run PHP in here? It would be much easier to achieve what you need with JS.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top