MC:Conditions in CSS vs. Inline Conditions: Battle Royale?

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
Wendy_Pod
Propeller Head
Posts: 21
Joined: Thu Jun 15, 2017 2:50 pm

MC:Conditions in CSS vs. Inline Conditions: Battle Royale?

Post by Wendy_Pod »

Hi all,

It seems the mc:conditions configured in my stylesheet are being beaten by inline conditions!?

The whole story is below, but after not getting the conditional output expected in our targets, I did some digging, and found a note tucked on the bottom of this page in the MadCap help, http://help.madcapsoftware.com/flare201 ... Styles.htm, which states:
Conditions that are set locally (i.e., directly on content) will override conditions set on a style. Even if the local condition is empty, it still overrides the conditions set from stylesheet.
So, if I’m reading this right, using stylesheet conditions will not work if we also apply conditions to those same elements inline.

Is this the case? Anyone else run into this? If so, what was your workaround?

We are trying to avoid having to explicitly set another condition on every element that we may want to conditionalize in secondary way.

Background…
  • Our project is conditionalized for two differently-branded product names (Product A and Product B), and has two targets, PDF and HTML5.
  • Each product has its own images/branding, each of which is appropriately conditionalized to Product A or B in our project.
  • We only want images to appear in PDF output, not in HTML5 output. This is true for both Product A & B.
To suppress images in for HTML5 output in simpler, single-product projects we used the stylesheet mc:conditions setting on the div tags that we use to contain our images. We set mc:conditions to apply a PrintOnly condition to the image divs, making it easy to prevent images from appearing in HTML5 output.

Unfortunately, in this multi-product project, the css mc:conditions setting seems to be trumped by the inline condition, resulting in a correctly branded HTML5 build, but including the undesired images.
SteveS
Senior Propellus Maximus
Posts: 2087
Joined: Tue Mar 07, 2006 5:06 pm
Location: Adelaide, far side of the world ( 34°56'0.78\"S 138°46'44.28\"E).
Contact:

Re: MC:Conditions in CSS vs. Inline Conditions: Battle Royal

Post by SteveS »

Hi Wendy,

That's the nature of cascading style sheets; anything further down the line will overwrite properties set up the line. Inline styling is the final setting. I'm guessing Madcap has followed the convention when setting up conditions in the stylesheet.

My only suggestion (not having tried it) is to try setting !important in the stylesheet to see if that has any influence.
Image
Steve
Life's too short for bad coffee, bad chocolate, and bad red wine.
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: MC:Conditions in CSS vs. Inline Conditions: Battle Royal

Post by NorthEast »

But have you set 'Include' on conditions in your target?
For example, if the product A/B condition is set to Include, then yes it will beat/trump the PrintOnly condition, because that's exactly what Include does.
If you apply two conditions on the same element, and one condition is set to Include, then it beats any condition that is set to Exclude.


As for using the mc-conditions property, my advice is to take care in how you use it.
What I do know:
* If a style uses mc-conditions, and then you manually apply a condition to the same element, then both conditions will be applied inline in the HTML code (you can see this happen in text view). So it automatically adds the condition from the stylesheet.
* If you change mc-conditions to another condition, this will only affect elements that have no existing (inline) condition. So, these elements will never be updated with the new condition.

I don't use mc-conditions because I find it way too unpredictable.
Wendy_Pod
Propeller Head
Posts: 21
Joined: Thu Jun 15, 2017 2:50 pm

Re: MC:Conditions in CSS vs. Inline Conditions: Battle Royal

Post by Wendy_Pod »

Thanks SteveS & Dave. Good to have that confirmed.

Dave, yes, we have a condition tag for each product, ProductA/ProductB, with each explicitly excluding the other for their respective targets.

Are you saying that if the same image is tagged inline for ProductA AND PrintOnly, with the target set to include ProductA but exclude PrintOnly, that the image will always appear? That include ProductA will trump exclude PrintOnly?
Nita Beck
Senior Propellus Maximus
Posts: 3667
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY

Re: MC:Conditions in CSS vs. Inline Conditions: Battle Royal

Post by Nita Beck »

Wendy_Pod wrote:Are you saying that if the same image is tagged inline for ProductA AND PrintOnly, with the target set to include ProductA but exclude PrintOnly, that the image will always appear? That include ProductA will trump exclude PrintOnly?
Yes. An explicit Include (meaning that you've ticked the Include box) will always trump an Exclude. An Exclude will always trump an implicit Include (meaning the Include box isn't ticked).
Nita
Image
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
Wendy_Pod
Propeller Head
Posts: 21
Joined: Thu Jun 15, 2017 2:50 pm

Re: MC:Conditions in CSS vs. Inline Conditions: Battle Royal

Post by Wendy_Pod »

Thanks Nita.

It would be great to have an flowchart that explicitly showed where the various conditions come into play and the impact of include exclude at each gate.

Perhaps, someday, if time permits... :wink:
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: MC:Conditions in CSS vs. Inline Conditions: Battle Royal

Post by ChoccieMuffin »

Just wondering, would you be able to use advanced conditions so that something that is [ProductA AND PrintOnly] is excluded for your target?

(I would love to give solid advice on this, but I ALWAYS have to look up the help and spend a good half an hour reading it whenever I'm playing about with advanced conditions to include and exclude stuff. It's very powerful, but a little bit complicated...)
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
devjoe
Sr. Propeller Head
Posts: 337
Joined: Thu Jan 23, 2014 1:43 pm

Re: MC:Conditions in CSS vs. Inline Conditions: Battle Royal

Post by devjoe »

You don't need advanced conditions. The solution is to set the help for product B to exclude ProductA and PrintOnly conditions. (If you have three products though, this will fail if you have things conditioned to appear in two products, unless you make something like a ProductsAandC condition and exclude it from B, and this solution rapidly spirals out of control if you have more products. Advanced conditions can be the best solution when you have too many different interlocking conditions.)

But we've veered away from the original question, which is based around having one condition set in the stylesheet and another condition set inline. The condition is an element value, so if it is being set on the same tag, indeed having it set inline trumps everything that was set in the stylesheet. You will either need to make sure that the inline conditions are set, for example, as ProductA,PrintOnly on such tags, or instead of using conditions, you can hide the element in the help only using display:none; in the main stylesheet and display:block; in the medium for the PDF output. (This latter solution also has a drawback: the content will still be accessible in the source, and if you are including only linked files in the help output, images in such sections may be considered linked even though they are not visible.)
Post Reply