Summary: Use your pub/css/ directory to collect and manage multiple css files automatically
Version: 2021-12-01
Prerequisites: None
Status: Active
Maintainer: Kirk Siqveland
Categories: CSS, CMS
Users: (view? / edit)
Discussion: ManageCSS-Talk?

Questions answered by this recipe

  • Can I manage multiple css files as separate files related to functions or features?

All sections are optional, you can remove those that do not apply to your recipe, and add new ones.


Easily use multiple CSS files to Manage distinct features

I like the built-in pmwiki/pub/css/local.css file as a means to manage css for my many features,
but I hate editing to be sure I remove the right code if I drop a feature, or only wanted to test something quickly.

ManageCSS.php simply reads all the .css files in the {pmwiki}/pub/css/ directory and assembles them into a new local.css file!

This way you can have separate CSS files for say a slide show, or special tables or for displaying your poetry, but keep them
in one place regardless of which skin you use.

You can now manage each file separately, using for example three files slideshow.css, specialtables.css and poetry.css
Once you have added the ManageCSS recipe, all you need to do is add or remove these files to the pmwiki/pub/css/ directory.
ManagaCSS will then automatically compile all of them into a new local.css which pmwiki loads each time a page is loaded.



Save your existing local.css file if you have one you already made.
ManageCSS will wipe the existing file and assemble a new one!

To Install:
Download and save the ManageCSS.phpΔ file to your {pmwiki}/cookbook directory
Then add the following line to your {pmwiki}/local/config.php file:



Just import or remove your CSS files from the {pmwiki}/pub/css/ directory.

If multiple CSS files manage common Elements, remember the files will be processed in alphabetical order.
That means the last one to be loaded will override things already defined by a previous file.
You may need to rename files to set the right order or pay attention to which elements you need to
manage with each file. e.g. does the SlideShow.css need to set the Font for <body>? This is where careful use of id= and class= comes in handy!


If you have future plans or wishes for this recipe.

Change log / Release notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See also



See discussion at ManageCSS-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.