$menu_icon not working in SS4.2.1

silverstripe-4
Tags: #<Tag:0x00007f10cf262640>

#1

Silverstripe Version: 4.2.1

After an update from SS4.0.3 to SS4.2.1, the custom menu icons won’t work anymore. Now it uses the fallback icon with the class “font-icon-circle-star”. The custom icons are placed in the themes folder.

private static $menu_icon = "themes/cms/icons/stop-grey.png";

#3

In ModelAdmin, the definition has changed from $menu_icon to $menu_icon_class


#4

Actually, $menu_icon_class is an additional option. $menu_icon still exists on LeftAndMain, which ModelAdmin extends from, so you should be able to use either :slight_smile:

@Carlo_R is your themes/cms/icons/ directory exposed as a public resource? 4.1.0 – SilverStripe Documentation


#6

True, but Carlo might have opted in. I think the docs encourage it.


#7

I’m working with @Carlo_R on this, so exposing the icons did seem to do the trick. But unfortunately still no correct icon :face_with_raised_eyebrow:

This is in the body of the document

.icon.icon-16.icon-toptenbookadmin { background-image: url('http://localhost/project.dev/public/resources/themes/klant/icons/book25px.png'); }

But that doesn’t seem to match the correct element:
<span class=“menu__icon font-icon-circle-star font-icon-toptenbookadmin”>&nbsp;</span>

So is it possible the .icon and .icon-16 are not used anymore? Or are we missing something else?


#8

I don’t know if this is related, but if you’re using the public directory structure then that should be your web root. So the URL should be more like http://project.dev/resources/themes/klant/icons/book25px.png


#5

Since it was an upgrade from 4.0.x to 4.2, it shouldn’t have forced the presence of the public directory structure I thought?


#9

thanks @JonoM, but the URL to the resource doesn’t seem to be the problem anymore. If I put it in my browser it just works.

Thing is, that the CSS selector doesn’t match the left-side of the admin-screen (with .icon.icon-16 in it).


#10

Looks like you found a bug! Appears that this line needs to be updated: silverstripe-admin/LeftAndMain.php at db9de461a957ae87e793113b07aabd795f5deaea · silverstripe/silverstripe-admin · GitHub

Would you care to create an issue and/or pull request to fix this?


#11

ah, I guess someone beat me to it: 1.2.x - private static $menu_icon has no effect · Issue #558 · silverstripe/silverstripe-admin · GitHub


#12

i’m using 4.4.1@stable in my composer.json

when i change the setting of private static $menu_icon its not changing in the cms … i’ve tried dev/build?flush=all …

flush=all and
flush=1

I’ve deleted everything in silverstripe-cache

i mistakenly set it to private static $menu_icon = “icons/banner.png”;

and although i’ve changed it to private static $menu_icon = “public/icons/banner.png”;
this is not refleceted in the browser inspector.
background-image: https://clientwebsitedomain.co.uk/icons/banner.png

default install site structure
public_html
app
public
icons
silverstripe-cache
themes
vendor
.htaccess {RewriteRule ^(.*)$ public/$1}

if i go to https://clientwebsitedomain.co.uk/public/icons/banner.png i see the image