1

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?

0

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
0

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

Your Answer

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

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