سؤال

In Magento 2.3.3 I add the following code to display the image in system configuration tab at Label but now not display image only display image tag as a text.

<tab id="mytab" translate="label" sortOrder="110">
    <label><![CDATA[<img src="http://logos-download.com/wp-content/uploads/2016/09/Magento_logo.png" width="100px"/>]]></label>
</tab>

enter image description here

هل كانت مفيدة؟

المحلول

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="section_id_here" translate="label" type="text" sortOrder="400" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Section label</label>
            <tab>tab_name</tab>
            <resource>Vendor_Module::acl_name</resource>
            <class>css-class</class>
        </section>
    </system>
</config>

Now you get a special class (css-class ) added to your section and you can control that via css files.

It works for tabs also but a bit different. The class must be added as an attribute

   <tab id="tab_id" translate="label" sortOrder="400" class="css-class">
        <label>Tab label</label>
    </tab>

نصائح أخرى

I had this problem too, you can override the template vendor/magento/module-config/view/adminhtml/templates/system/config/tabs.phtml this way :

<div class="admin__page-nav-title title _collapsible" data-role="title">
    <strong>
    <?php
    $label = $_tab->getLabel();
    echo strpos($label, '<img') !== false
                            ? $label
                            : $block->escapeHtml($label)
    ?>
    </strong>
</div>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top