1

I'm trying to add in an image next to a dropdown item, alongside the title. Is this possible? I've seen it being done with items in the sidebar under System > Configuration before, but never in the top menu. Being able to do something like this would be great, for example:

<menu>
    <system>
        <children>
            <example>
                <title><img src="foo.png" />Example</title>
                <action>adminhtml/example/index</action>
            </example>
        </children>
    </system>
</menu>

Obviously that's not going to work, so any pointers would be highly appreciated. Thanks in advance!

1 Answer 1

2

You can add a class to the title like below

<menu>
        <custom_module module="custom_module" translate="title">
        <title><![CDATA[<span class="custom_module">Custom Module</span>]]></title>

And then add a adminhtml layout file to add some css to add the image to your menu item.

Update:

Ok so it looks like this only worked for me because I have an extension installed that overwrites Mage_Adminhtml_Block_Page_Menu::getMenuLevel and updates line 301 to not have the $this->escapeHtml wrapper on the label.

            . $this->escapeHtml($item['label']) . '</span></a>' . PHP_EOL;
6
  • I've tried this, but the HTML gets output as plain text.
    – Thierry
    Commented Sep 6, 2014 at 21:24
  • Fair point, I must have missed something, will let you know if I find it. Commented Sep 6, 2014 at 21:47
  • Much appreciated.
    – Thierry
    Commented Sep 6, 2014 at 21:51
  • I've updated my answer @Thierry Commented Sep 6, 2014 at 22:22
  • Ah, well, that's not going to be a viable solution for me then. I guess that answers my question. Thanks for the information and your time!
    – Thierry
    Commented Sep 6, 2014 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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