Custom CSS in Jupiter for main cPanel interface - How to add your own stylesheet
Webmail interface - How to add your own stylesheet
Summary:
We add a new LESS partial file to the pre-existing base_overrides LESS and then recompile
. This method requires good familiarity with LESS, CSS preprocessors, and minification. Why? A custom stylesheet allows administrators to customize the cPanel interface in order to align it more closely with their own branding. It can also be used as a kludge to hide some page elements that administrators don't want their users to interact with. Elements hidden using CSS are still visible in the source code, so this is not a perfect or long-term solution. But custom CSS offers a quick, simple way of modifying the interface without worrying about introducing serious new bugs or security risks. Details: The Jupiter theme for the main cPanel interface on my system is stored here:
My strategy for making changes here requires good familiarity with the CSS preprocessor LESS and with CSS minification. The main cPanel Jupiter files already include a CSS override file named
located here:
cPanel seems to use this for its own overrides to a few elements of Jupiter that for whatever reason aren't fixed at source. The LESS files that generate base_overrides are located in a subfolder here:
and are called from here:
That LESS file simply calls the Index file found in the base_overrides folder:
Rather than editing page templates or scripts, to add a custom stylesheet, you can simply add your own CSS overrides to the base_overrides that cPanel already includes. To do this, you create your own LESS partial file (I begin the filename with an underscore following common SASS practice and to match the cPanel coding style here), add your CSS or LESS to it, and then add that file to the base_overrides folder here like so:
THEN explicitly import your new LESS file by adding an import reference to it at the end of the
file in the same folder. In my install, these are lines 10 and 11 of
:
Then compile the
file and upload the
to your server in the same location where you found it. I found that in order to compile
locally, I needed to add the following two LESS files that are referenced by base_overrides in addition to adding all the base_overrides folders, subfolders and files:
As an example of what you can do with this cPanel CSS override file, I have added the following code to
in order to hide the Horde notification that currently cannot be disabled by owners or properly dismissed by users:
It is unclear how often the base_overrides.min.css file will be overwritten by cPanel updates, or if it will in fact be removed entirely at some point in the future. But since these edits result in a change only to that single CSS file, then the worst that will happen if they are overwritten is that your users will see the default cPanel interface instead of your customized version.
base_overrides.min.css. This method requires good familiarity with LESS, CSS preprocessors, and minification. Why? A custom stylesheet allows administrators to customize the cPanel interface in order to align it more closely with their own branding. It can also be used as a kludge to hide some page elements that administrators don't want their users to interact with. Elements hidden using CSS are still visible in the source code, so this is not a perfect or long-term solution. But custom CSS offers a quick, simple way of modifying the interface without worrying about introducing serious new bugs or security risks. Details: The Jupiter theme for the main cPanel interface on my system is stored here:
/usr/local/cpanel/base/frontend/jupiterMy strategy for making changes here requires good familiarity with the CSS preprocessor LESS and with CSS minification. The main cPanel Jupiter files already include a CSS override file named
base_overrides.min.csslocated here:
.../jupiter/css/base_overrides.min.csscPanel seems to use this for its own overrides to a few elements of Jupiter that for whatever reason aren't fixed at source. The LESS files that generate base_overrides are located in a subfolder here:
.../jupiter/css/base_overridesand are called from here:
.../jupiter/css/base_overrides.lessThat LESS file simply calls the Index file found in the base_overrides folder:
.../jupiter/css/base_overrides/index.lessRather than editing page templates or scripts, to add a custom stylesheet, you can simply add your own CSS overrides to the base_overrides that cPanel already includes. To do this, you create your own LESS partial file (I begin the filename with an underscore following common SASS practice and to match the cPanel coding style here), add your CSS or LESS to it, and then add that file to the base_overrides folder here like so:
.../jupiter/css/base_overrides/_my_cpanel_overrides.lessTHEN explicitly import your new LESS file by adding an import reference to it at the end of the
index.lessfile in the same folder. In my install, these are lines 10 and 11 of
index.less:
// My custom overrides to Jupiter
@import "_my_cpanel_overrides.less";
Then compile the
base_overrides.lessfile and upload the
base_overrides.min.cssto your server in the same location where you found it. I found that in order to compile
base_overrides.lesslocally, I needed to add the following two LESS files that are referenced by base_overrides in addition to adding all the base_overrides folders, subfolders and files:
.../jupiter/libraries/base-styles/variables.less.../jupiter/shared/css/jupiter.lessAs an example of what you can do with this cPanel CSS override file, I have added the following code to
_my_cpanel_overrides.lessin order to hide the Horde notification that currently cannot be disabled by owners or properly dismissed by users:
// Hide Horde Banner
#cpHordeBanner {
display: none !important;
}
It is unclear how often the base_overrides.min.css file will be overwritten by cPanel updates, or if it will in fact be removed entirely at some point in the future. But since these edits result in a change only to that single CSS file, then the worst that will happen if they are overwritten is that your users will see the default cPanel interface instead of your customized version.
-
[Reserved for revision notes] 0 -
This is very interesting... 0
Please sign in to leave a comment.
Comments
2 comments