Multiple style sheets

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
RiverMonster
Sr. Propeller Head
Posts: 149
Joined: Fri May 09, 2008 8:51 am
Location: Alicante, Spain
Contact:

Multiple style sheets

Post by RiverMonster »

Hi,

95% of my topics use one CSS while 5% use another. I would like to be able to set a default CSS for the whole project but be able to override it for particular topics. Right now this does not seem to be possible. If I set a CSS at the project level it is no longer able to set a CSS at the topic level. I tried adding the link to the <head> of the topics but it just gets ignored (in both the XML editor and the output).

I suppose this is just how MadCap chose to implement this rather than being a CSS limitation?

Maybe next to the "Master Stylesheet" field in the Project Properties dialog there could be a check box labeled "Allow topic-specific stylesheets"? Would this make sense?

Thanks,

Adrian
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Multiple style sheets

Post by NorthEast »

The master stylesheet will replace all stylesheet links in the output topics. So don't use it if you have topics that use different stylesheets, or have topics that have more than one stylesheet link.

You could control this using master pages; have two master pages, and set the appropriate stylesheet link in each master page.
This kb article describes how to use multiple master pages: http://kb.madcapsoftware.com/mobile/Adv ... roject.htm


An alternative method would be to use just a single stylesheet, and use complex selectors to define any differences in styles.
For example, the CSS below would give you green text in a normal topic, and red text in any topic with a style class of 'different'.
body { color: #00ff00; }
html.different body { color: #ff0000; }
RiverMonster
Sr. Propeller Head
Posts: 149
Joined: Fri May 09, 2008 8:51 am
Location: Alicante, Spain
Contact:

Re: Multiple style sheets

Post by RiverMonster »

Thanks Dave. You have confirmed the way I thought it worked, but not really answered my question. To phrase it a different way, I am considering putting in an enhancement request to have a setting that controls whether or not you can still apply a topic-specific CSS when you have set a CSS for the whole project. So if you dont have this setting enabled it would work like it does now, but if you do have the setting enabled it means that the project CSS would be applied to all topics that dont have any other CSS directly applied to them. Is there any limitation in CSS that would prevent such functionality?

Cheers,

Adrian

PS I cant use your suggestion of multiple master pages for sorting this out with current functionality because this is for PDF output.
kwag_myers
Propellus Maximus
Posts: 810
Joined: Wed Jul 25, 2012 11:36 am
Location: Ann Arbor, MI

Re: Multiple style sheets

Post by kwag_myers »

I can't answer your original question, but I would like to offer a possible work-around.

I'm using a separate CSS for the cover page of my PDF outputs. My approach to this is to set up my own project template where one topic uses the cover.css and another topic uses my default.css, which is set in the topic properties. This would allow you to select the desired topic/css when you add a new topic.

It sounds like you might be pretty well into your project and, if so, this might not work for your situation. If that's the case, can you remove the project level CSS? You might be able to add the default CSS to the source code of your topics using the Find/Replace feature, then go back and set the Properties > Topic Properties for those topics to use the alternate CSS. I'm using Flare 8, so I'm not sure if this is available on older versions. If not, there are some free global replace apps that can do it instead.
"I'm tryin' to think, but nothin' happens!" - Curly Joe Howard
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Multiple style sheets

Post by NorthEast »

RiverMonster wrote:To phrase it a different way, I am considering putting in an enhancement request to have a setting that controls whether or not you can still apply a topic-specific CSS when you have set a CSS for the whole project. So if you dont have this setting enabled it would work like it does now, but if you do have the setting enabled it means that the project CSS would be applied to all topics that dont have any other CSS directly applied to them. Is there any limitation in CSS that would prevent such functionality?
There aren't any limitations with CSS, just how Flare handles stylesheets.

In practice, I think a system like that might introduce some new problems; e.g.:
- What happens if you decide not to use this feature, but have set up your project so that most topics don't have stylesheet links?
- How would you set up a project to use this for one target but not another?
- Existing projects will include stylesheet links, so you'd have to remove them.
- The editor wouldn't display any styles for topics with no stylesheet link (apart from a few core styles - p, h1-6, etc.).

I totally agree it needs improvement though; I think Flare's stylesheet handling needs an overhaul, it's confusing and inconsistent as it stands.
kwag_myers wrote:You might be able to add the default CSS to the source code of your topics using the Find/Replace feature, then go back and set the Properties > Topic Properties for those topics to use the alternate CSS. I'm using Flare 8, so I'm not sure if this is available on older versions. If not, there are some free global replace apps that can do it instead.
Note that you can apply topic properties to groups of topics at a time; you can select multiple topics in Content Explorer (with Show files), or the File List.
i-tietz
Propellus Maximus
Posts: 1219
Joined: Wed Oct 24, 2007 4:13 am
Location: Fürth, Germany

Re: Multiple style sheets

Post by i-tietz »

You can have a stylesheet on project level, on target level and on topic level.
If you have a stylesheet on project level you CANNOT assign a stylesheet to topics.
If you have a stylesheet on target level you CAN assign a stylesheet to topics - preferably only to those 5% that differ. To do that via using another template (including the stylesheet assignment) for them is a good idea.
Inge____________________________
"I need input! - Have you got input?"
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Multiple style sheets

Post by NorthEast »

i-tietz wrote:If you have a stylesheet on target level you CAN assign a stylesheet to topics - preferably only to those 5% that differ.
I think you're confusing the stylesheet links option, with what actually happens in the output.

The stylesheet links option may or may not be available; it's only available if the primary target does not use a master stylesheet.
And whether you can/can't set stylesheet links is irrelevent if you are going to use a master stylesheet.

The important point is that if you set a master stylesheet on a target, it will completely replace any stylesheet links in your topics in that target's output.
So if you need to use two different stylesheets, you cannot set a master stylesheet on either a target or a project.
Spectre
Sr. Propeller Head
Posts: 128
Joined: Tue Jun 17, 2008 5:50 am

Re: Multiple style sheets

Post by Spectre »

Hi,

Let's say you want to use a different style sheet for a target than you have specified at Project level, under Project Properties. When I do this, I'm finding that the CSS that I'm using at Target level is being applied within Flare's editor, when I'd have expected the Target style sheet to only come into play in the generated output. Does this surprise anyone?

Thanks.
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Multiple style sheets

Post by NorthEast »

Spectre wrote:Hi,

Let's say you want to use a different style sheet for a target than you have specified at Project level, under Project Properties. When I do this, I'm finding that the CSS that I'm using at Target level is being applied within Flare's editor, when I'd have expected the Target style sheet to only come into play in the generated output. Does this surprise anyone?

Thanks.
The XML editor will show what your primary target looks like; i.e. the output type, stylesheet and medium.

In your case - if your primary target has a master stylesheet, you'll see that stylesheet; otherwise, you'd see the project level stylesheet.
Or if you don't set any master stylesheets, the editor will use the stylesheet linked from the topic itself.
Spectre
Sr. Propeller Head
Posts: 128
Joined: Tue Jun 17, 2008 5:50 am

Re: Multiple style sheets

Post by Spectre »

Thanks Dave. Yes, you're quite right, if I switch the primary target, I get the result I want, with one CSS used for the primary target and the Flare editor, and another for the secondary target.
Johanna
Propeller Head
Posts: 25
Joined: Wed Feb 25, 2015 3:08 am

Re: Multiple style sheets

Post by Johanna »

I have two projects that I would like to merge.
Each of them has a different style sheet defined at project level.
I would like to put the two projects into one while keeping the two distinct style sheets for the same target (HTML5).
So each topic should use the style sheet it was using before the merge.

If I understand the discussions under this subject correctly, it means I should define the style sheet on topic level only.
In Flare I am not sure to understand I can de-activate the selection of the style on project level. Should I set it to <default>?
Is there some automatic way to transfer the project level style sheet information to all topics before the merge?
I have many files so would be huge work to do one-by-one.
Spectre
Sr. Propeller Head
Posts: 128
Joined: Tue Jun 17, 2008 5:50 am

Re: Multiple style sheets

Post by Spectre »

Johanna,

You could add a css to the topics in project 1, at topic level, before you merge it with project 2.

To do this, in project 1, set the css in Project Properties to default, and do the same for any targets. Then, at the top of Content Explorer, click the second button from the left (Toggle Show Files). This splits the Content Explorer screen, showing the topics for the selected folder on the right. Now, click shift to select the topics that you want to change, right click and select Properties, and select the required css. If the Stylesheet drop-down is greyed out you need to check whether you've set Project Properties and Targets to default.

However, I'm not sure what that gives you. You're going to be setting one stylesheet in the Target when you create an output, and that stylesheet will override any topic level css - that is my understanding anyway. I've read that it's best practice to keep the topic level css set to default.

Cheers.
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Multiple style sheets

Post by NorthEast »

I'd suggest something similar-ish, but I'd use the File List rather than Content Explorer...

Before you merge the projects, in each project:

1. Remove any master stylesheet set on the target or project - i.e. set it to (default)
2. Open the File List pane and set it to filter by topic (*.htm, *.html) - to show all topics in your project.
3. Select all the files in the list, then press F4 to open the properties. Then choose the Stylesheet to use.

That will make sure all your topics include a stylesheet link, before you merge the projects.
Spectre wrote:However, I'm not sure what that gives you. You're going to be setting one stylesheet in the Target when you create an output, and that stylesheet will override any topic level css - that is my understanding anyway. I've read that it's best practice to keep the topic level css set to default.
Your understanding is correct, but you're not going to set a master stylesheet as that would override the topic stylesheet links. Just leave the master stylesheet in the target and project set as (default), and your topic stylesheet links will work fine.
Spectre
Sr. Propeller Head
Posts: 128
Joined: Tue Jun 17, 2008 5:50 am

Re: Multiple style sheets

Post by Spectre »

Ah yes, of course. Thanks Dave.
Johanna
Propeller Head
Posts: 25
Joined: Wed Feb 25, 2015 3:08 am

Re: Multiple style sheets

Post by Johanna »

Great!
Thank you very much.
Post Reply