cancel
Showing results for 
Search instead for 
Did you mean: 

Override core XML layouts from adminhtml

SOLVED

Override core XML layouts from adminhtml

Hi guys,

 

On Magento 2.3.0, there are some issues regarding logo upload for header section or for transactional emails (Content -> Design -> Configuration -> My Theme (edit) -> ...). 

 

I tried to override design_config_form.xml, both from module-theme and module-email in my custom module, so that I can change fileUploader with imageUploader, and I'm asking how should I do this?

 

So far I succeeded somehow, but I'm still confused why it's working. Basically, I created in my custom module a file called design_config_form.xml under view/adminhtml/ui_component and changed fileUploader with imageUploader. Somehow it worked, but I don't know why because I didn't add the sequence in module.xml. 

Also, there are two files with the same name (design_config_form.xml), both from different modules and I want to override them in the same module. How can I do that?  

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Override core XML layouts from adminhtml

Hi @Anonymous ,

 

Magento merges xml config into one. design_config_form.xml merge according to sequence order. In your case, this is missing and order by module name. You can combine two xml by following way:

 

app/code/SR/MagentoCommunity/view/adminhtml/ui_component/design_config_form.xml

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="other_settings">
        <fieldset name="head">
            <field name="head_shortcut_icon" formElement="fileUploader">
                <settings>
                    <notice translate="true">Not all browsers support all these formats!</notice>
                    <label translate="true">Favicon Icon</label>
                    <componentType>imageUploader</componentType>
                </settings>
                <formElements>
                    <imageUploader>
                        <settings>
                            <allowedExtensions>jpg jpeg gif png ico apng</allowedExtensions>
                            <maxFileSize>2097152</maxFileSize>
                            <uploaderConfig>
                                <param xsi:type="string" name="url">theme/design_config_fileUploader/save</param>
                            </uploaderConfig>
                        </settings>
                    </imageUploader>
                </formElements>
            </field>
        </fieldset>
        <fieldset name="email">
            <field name="email_logo" formElement="fileUploader">
                <settings>
                    <notice translate="true">To optimize logo for high-resolution displays, upload an image that is 3x normal size and then specify 1x dimensions in the width/height fields below.</notice>
                    <label translate="true">Logo Image</label>
                    <componentType>imageUploader</componentType>
                </settings>
                <formElements>
                    <imageUploader>
                        <settings>
                            <allowedExtensions>jpg jpeg gif png</allowedExtensions>
                            <maxFileSize>2097152</maxFileSize>
                            <uploaderConfig>
                                <param xsi:type="string" name="url">theme/design_config_fileUploader/save</param>
                            </uploaderConfig>
                        </settings>
                    </imageUploader>
                </formElements>
            </field>
        </fieldset>
    </fieldset>
</form>

 

-----
If Issue Solved, Click Kudos and Accept As solutions.
Sohel Rana, 7x Magento 2, 2x Magento 1 Certified

View solution in original post

3 REPLIES 3

Re: Override core XML layouts from adminhtml

Hi @Anonymous ,

 

Magento merges xml config into one. design_config_form.xml merge according to sequence order. In your case, this is missing and order by module name. You can combine two xml by following way:

 

app/code/SR/MagentoCommunity/view/adminhtml/ui_component/design_config_form.xml

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="other_settings">
        <fieldset name="head">
            <field name="head_shortcut_icon" formElement="fileUploader">
                <settings>
                    <notice translate="true">Not all browsers support all these formats!</notice>
                    <label translate="true">Favicon Icon</label>
                    <componentType>imageUploader</componentType>
                </settings>
                <formElements>
                    <imageUploader>
                        <settings>
                            <allowedExtensions>jpg jpeg gif png ico apng</allowedExtensions>
                            <maxFileSize>2097152</maxFileSize>
                            <uploaderConfig>
                                <param xsi:type="string" name="url">theme/design_config_fileUploader/save</param>
                            </uploaderConfig>
                        </settings>
                    </imageUploader>
                </formElements>
            </field>
        </fieldset>
        <fieldset name="email">
            <field name="email_logo" formElement="fileUploader">
                <settings>
                    <notice translate="true">To optimize logo for high-resolution displays, upload an image that is 3x normal size and then specify 1x dimensions in the width/height fields below.</notice>
                    <label translate="true">Logo Image</label>
                    <componentType>imageUploader</componentType>
                </settings>
                <formElements>
                    <imageUploader>
                        <settings>
                            <allowedExtensions>jpg jpeg gif png</allowedExtensions>
                            <maxFileSize>2097152</maxFileSize>
                            <uploaderConfig>
                                <param xsi:type="string" name="url">theme/design_config_fileUploader/save</param>
                            </uploaderConfig>
                        </settings>
                    </imageUploader>
                </formElements>
            </field>
        </fieldset>
    </fieldset>
</form>

 

-----
If Issue Solved, Click Kudos and Accept As solutions.
Sohel Rana, 7x Magento 2, 2x Magento 1 Certified

Re: Override core XML layouts from adminhtml

Hi @Sohel,

 

Thank you, it's working. But, how should I do it if I want to override two or three XMLs, with different fieldsets, in the same module?   

 

PS. Somehow, I successfully overwritten the default_config_form.xml from module-theme in app/code/TemplateMonster/ThemeOptions/view/adminhtml/ui_component.

Re: Override core XML layouts from adminhtml

Hi @Anonymous ,

 

You need to create the same xml file for this. In your case, default_config_form.xml inside you can add as many fieldsets as you want or overwrite it. Also, your module name is TemplateMonster_ThemeOptions that's why this is loaded last where you did not add sequence though.

-----
If Issue Solved, Click Kudos and Accept As solutions.
Sohel Rana, 7x Magento 2, 2x Magento 1 Certified