Users have asked if there is a way to style a condition so that it appears a certain way in Flare’s outputs. Here is a little trick to accomplish just that.
The first step is to make sure that you have a condition applied to an element in your topic. In this sample, we’ll use the “Default” Conditonal File Set and the PrintOnly Condition in it. Then follow these steps:
- Create an “Empty” Flare Project (Using the Empty Template Provided)
- Choose WebHelp as the output type
- Open the only topic in the editor
- Select the text or paragraph that you want to apply the Conditional Tag to.
- Go to Format > Condtions… and select “PrintOnly”
- Click “Ok” and save
- In the Content Explorer, Open the Stylesheets folder
- Right-click on the Styles.css and open with Notepad
- Copy the CSS code from below and paste it at the end of the stylesheet
- Save and close Notepad
- Build the WebHelp output and view the results. You should see the text or paragraph that you selected with a grey background.
CSS code:
For WebHelp:
[MadCap\:conditions*="Default.PrintOnly"] { background-color: #C0C0C0; }
For HTML5 Output:
[data-mc-conditions*="Default.PrintOnly"] { background-color: #C0C0C0; }
For both outputs:
[MadCap\:conditions*="Default.PrintOnly"], [data-mc-conditions*="Default.PrintOnly"] { background-color: #C0C0C0; }
Remember, if you apply this to a condition that is set to be removed in the Target, it will not appear at all in the output.
Note: The CSS to achieve this is not yet supported in our internal CSS editor, so if you want to make a change, edit, or create a more, you will have to use notepad or another CSS editor.
Great tip!! Any way to do the reverse? Add a condition setting to a style? Several of my styles are for screenonly paragraphs. It would be great if the condition got set automatically when I applied the style. Something like:
p.screenlinks
{
madcap_conditions: “Default.ScreenOnly”;
}
thanks, we have been using this awesome hack with webhelp for some time. just tested it with html5 output, but no dice. have you dreamed up a similar fudge for html5 output? would also be great if you had a pdf friendly version 🙂
thanks
owen
duh. on second reading, you already answered my question. you simply rock.
This is a great tip
Is there a way to apply conditions to print output. For example adding a background image when a “Draft” condition is set?
You wouldn’t use a condition in this instance, instead you have the option of using either a stylesheet medium (background image on the body tag), or a page layout with a background configured. More info on both of these options can be found in our help articles linked below. Please follow up with any questions you may still have!
Setting the “Draft” background image in a page layout:
https://help.madcapsoftware.com/flare10/Default.htm#Page_Layouts/Pages/Specifying_Page_Background_Settings.htm
Creating a background “watermark” using a css class:
https://help.madcapsoftware.com/flare10/Default.htm#Images/More_About_Images/Creating_Watermarks.htm
Its been a while since this post but would love to know how to make this work with PDF outputs.
I tried both code examples in my CSS but no impact.
Any suggestions?
Hi Chris! Thanks for your comment. After some testing, we discovered that there isn’t a way to preserve this in PDF. We have submitted this to R&D on your behalf, I do hope we can support it soon.
Hi, I don’t remember where I found the “add-on” to your fix that can work with Word output, but I have added the following to my print media section in my CSS:
MadCap|conditionalText
{
background-color: #f8fc7e;
}
This works great, except that it is applied to all conditional text – I want it to just apply to my “Comment” condition (the one I use for SME questions). Is there a way to specify just that condition in the css? I’m not a CSS wizard, so I apologize if this is elementary!
Hello Laurie,
Thanks for your comment! It seems it currently isn’t supported to declare a specific conditional tag to be styled by Flare. However, we’ve submitted this as a feature request and you’ll receive an email if it’s include in a future release.
Thanks!
Rachel
I know it’s been awhile since the OP, but this doesn’t seem to work with table rows. Any hack to get that to work?
Hi Wendy,
This also works with table rows as well! If you are running into difficulties setting this up, please contact our technical support team and they can check out whats going on in your project. https://www.madcapsoftware.com/support/contact-options.aspx