Implementing plugins/modules with css?

Hi

My site has been designed with html many moons ago. It basically has a html template and all the php generated content is merged into the html template. This has worked rather well for me and considering it was all home made as a learner i was rather chuffed with it at the time.

Lately i’ve decided that i must master CSS. I know its odd to learn php, html and no css but thats just what suited me at the time.

I have tonight thought of a bit of a problem:
My site has its own home brewed CMS which allows me to use my own modules which are picked up and automatically linked into the menu so i don’t have to manually change the links all over the place. This was fine with pure html but i’ve since realised that this is now going to be useless for the content generated by each module css wise because a stylesheet can’t have css for everything that a future module might expect.

So, what are my options here?
I suppose i could output a <styles> section in the head of the html template for each module and then just use the stylesheet for the main template layout. Is this the best way forward?

You don’t want to have too many style sheets. You could just add in the styles for a module at the end of your site style sheet when appropriate, or perhaps have a separate style sheet for all of your modules if you want a bit of separation.

I did think about that but i’d need to write the css to the style sheet when the module is installed etc. Can I use multiple external sheets?

You could put in beforehand if you want. You can add styles any time you like.

Can I use multiple external sheets?

Yes, but as I said, don’t use more than needed, as each new call to the server slows things down. Any time you add something new to a site, you need to add CSS styles for it somewhere. I’m not sure what your dilemma really is. It’s not a big job just to add in some styles to your style sheet now and then. I’d say that’s much easier than trying to devise some kind of automated process of feeding new styles in.

You’re right it isn’t a big job i just wanted to be sure it was the best way forward.

Thanks for your help :wink:

Place the CSS in separate physical location based on module and then aggregate what is needed using a single request. Essentially, have back-end code serve up the CSS dynamically so it can take all the stylesheets, aggregate the ones needed and add caching.