I need a little guidance here in how to best handle loading multiple stylesheets based on the current weblog. My current structure is that I have a header and footer template and then embed those into all my templates/weblogs. The main css file for the site is linked in the header. How would I then add a weblog-specific stylesheet a particular template? Is there a stylesheet add-on manager for such cases? I know this probably has been asked many times but couldn’t find a thread on it.
Thanks.
Chris,
Depending on your specific needs, you can just create a new html header embed template and link to that on the weblog that needs to access that CSS file. In other words, you can create a new CSS file as a template, say “style_2”, and the embed tags on the weblogs needing it would include that reference.
I use a template group for embeds (for easier management – not required), and in that group there are several “html_header_x…” templates. A couple are for different scripts or metadata, but a couple are for different CSS links. I prefer not to separate too much of the CSS so that a visitor doesn’t experience any slowdown while the additional files are being loaded into cache, but there are times when separation is simply preferred. For example, a blog and several other pages can use the main CSS, while a Gallery section displaying several portfolios can use a different CSS file controlling it.
Just name your different header templates to be embedded something different, e.g. html_header_main, html_header_gallery, html_gallery_blog, etc. and set the path to them in your embed tag as needed.
The same applies if the footer elements are different in certain sections. Create a different footer file to embed on the pages that require the different footer (or any other element).
HTH,
Dale