Jump to content

Adding BO CSS style to assign glyph icon to new menu tab via module?


Recommended Posts

I am creating a module which i will be using to add some functionality to my shop.

 

On installing the module it creates a new tab in the back office menu, by default there is no styling assigned to this class (as its the name of the custom controller). It also has no glyph icon assigned to it.

 

So in my module css file i add this:

 

.icon-AdminPricingUpdate:before {
    content: "\f074" !important;
}

 

And now when i navigate to the tab, it adds the glyph icon (icon-random) to the menu and the tab title.

 

If i browse to another tab, it goes back to no glyph icon as there is no longer a style file loaded.

 

How do I ensure that this style gets applied no matter what view the back office is in?

 

It would basically be adding this to admin-theme.css but I do not want to manually add it, I would like to do this within the module installation.

 

Any help would be appreciated, thanks!

Link to comment
Share on other sites

We are experiencing a similar issue; and have had limited success using setMedia in the ModuleAdminController. We are also very reluctant to modify the admin-theme.css file aswell!  I don't understand why the icons have been hard coded into the admin-theme.css, apart from performance/keeping the number of header files down to a manageable number.

 

If initBreadcrumbs method or the Tab class (database) restored the ability to have the icon class defined by a menu (1.5) or through a method call.

Link to comment
Share on other sites

Looking at the documentationI think there might be a simpler solution. Add a hook to displayBackOfficeHeader, so that on each page load it adds a special css file that contains the .icon-Adminxxxx { content: "\f000"; } ...

public function hookDisplayBackOfficeHeader()
{
   $this->context->controller->addCss($this->_path.'css/tab.css');
}
Edited by contentengineer (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...