How can I override a ui_components' template file?
The concerning file is:
vendor/magento/module-ui/view/base/ui_component/templates/listing/default.xml
I want to override this file so that it adds a CSS class to the div specific for the widget used.
I've tried copying the file to: app/design/frontend/Vendor/Theme/Magento_Ui/ui_component/templates/listing/default.xhtml
But this hasn't worked, even after flushing all caches and performing setup:upgrade I don't see any changes made on the frontend.
Making the change directly in the original file under vendor does however have an effect, so I'm sure that I'm editing the right file.
Someone that has an idea?
2 Answers 2
The file you try to copy is an XML file, but you set it as XHTML in the copied version.
app/design/frontend/Vendor/Theme/Magento_Ui/ui_component/templates/listing/default.xhtml
that should be:
app/design/frontend/Vendor/Theme/Magento_Ui/ui_component/templates/listing/default.xml
if you know the ui_component name like "customer_listing". You can update this ui_component's template inside your_module/view/adminhtml/ui_component/customer_listing.xml:
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration. xsd">
<argument name="data" xsi:type="array">
<item name="template" xsi:type="string">templates/my_template</item>
</argument>
</listing>
The 'my_template.xhtml' file will be located and copy the "default.xhtml" content into this file.
your_module/view/adminhtml/ui_component/templates/my_template.xhtml