Jump to content
Grotlek

Linking or re-directing one CSS entry to another?

Recommended Posts

Hiyas, I have tried searching for this but came up blank, so I'd appreciate any pointers in the right direction. I'm trying to integrate a web-site. As there's no "one content manager fits all" solution that suits my needs, I'm using a mixture of different PHP-based products. Each of these products ships with their own CSS files to manage the appearance of their generated content. My aim is to give the site a consistent look and feel. I've already written a stylesheet that has the different styles my site needs, but each product uses its own CSS classes. My options appear to be: 1. Modify each of the PHP applications to link to my stylesheets, not their own. This causes a maintenance headache though, because I'll constantly be tweaking updated code.2. Copy and paste the relevant stylesheet bits into the applications' CSS files, replacing the original CSS with my own. This is less of a headache because it's easier to maintain, but is duplicating all the elements, and whenever I want to change styles of the main site, I have a bunch of extra stylesheets to keep in sync. This is returning to the problem that CSS was designed to solve!3. Find some way of linking the stylesheets. So having some stylesheet entry that effectively says "for acme-corp-style-for-class-xyz go use mysite-style-for-class-abc". Thus having only one "master" stylesheet that everything else points to. This seems a sensible way (at least to my newbish mind). ... But I can't find any way of achieving #3. Is it possible to "redirect" style sheet entries in this way? ... Or is there a better way of doing what I'm trying to do? Thanks in advance for any advice and suggestions :-).

Share this post


Link to post
Share on other sites

I don't know what all you have tried, but PHP can dynamically generate the CSS. Maybe not the best solution, but the power of PHP is always neglected. For some reason, people believe that files have to be a certain type, but PHP files can output whatever you want. RSS feeds can even be PHP files that just output xml code. Anyways, I hope this idea helps.

Share this post


Link to post
Share on other sites

Hi Jardrake, and thanks for the reply. Actually you have given me an idea. Since I'm already "top and tailing" the content so it appears within my site's styles, I could do a replacement on the class ids that the third party code pumps out before sending it to the end user. There'll be a bit of maintenance but a lot less than trying to patch the third party code every time I update it. A bit of a hack, since trying to parse html is fraught with potential problems, but with a limited scope of the replacements, I can probably get away with it. Although knowing myself, I'll probably scope creep that search/replace function a bit... :-). Alternatively, I suppose I could write a script that takes the CSS file and updates the styles from my master appropriately. That'd reduce the work the PHP server has to do, since I only have to run it once whenever I change something in the CSS. So I'm guessing there's no way of saying "for this stylesheet class id, cascade this other one into it" in CSS itself? :-(.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...