Automatic Styles in Condition Tags?

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
wbrisett
Sr. Propeller Head
Posts: 216
Joined: Mon Oct 05, 2009 3:29 pm
Location: Austin, TX

Automatic Styles in Condition Tags?

Post by wbrisett »

I'm trying to setup a test project from FrameMaker that has conditional indicators. The manager wants to be able to maintain what he had in FrameMaker, which is the reviewers see things in the various colors indicating to them what part of the text goes to the various people (the conditions). In FrameMaker they have the text colored for each condition. I found I can create a new style in the css so that

The condition ProductA has a style of producta, but I have to manually assign that style to the text. Are there any ways to automatically have styles applied to conditions?

Or is there a better way to do this? I also have to think about removing them when the final document is produced.

Wayne
ajturnersurrey
Sr. Propeller Head
Posts: 346
Joined: Fri Nov 05, 2010 3:30 am

Re: Automatic Styles in Condition Tags?

Post by ajturnersurrey »

I work with a lot of condition tags - mainly to highlight data in manuals which comes in from a particular software version.

Visually, as the Flare user, I see these things neatly colour coded on the structure bars along the lefthand side of the display. Because I set up the condition "from_v8" to be orange, I see orange sections in the structure bars on the left for any text I have given that condition, etc..

If you used condition tags to highlight content owners/authors you can see it in Flare (or Contributor) in that way. You are not using css to change the text colour, and this is all completely invisible in any outputs. Though you could choose to produce an output which only contained stuff for which Joe Bloggs was the owner, for example.

I personally use File tags to identify contributors, because I only have one contributor per topic. The file tag attaches to a topic and allows me to search and report on all topics with a given file tag.
wbrisett
Sr. Propeller Head
Posts: 216
Joined: Mon Oct 05, 2009 3:29 pm
Location: Austin, TX

Re: Automatic Styles in Condition Tags?

Post by wbrisett »

Maybe I wasn't being clear enough. I understand how the condition tags work in Flare. However, we use a PDF for our review process, so we actually DO want things to show up in different colors so the reviewers can tell what information is for what product.

Do do this, I created the conditions we wanted to use, then I added classes for each condition that matched the conditional indicator color in Flare (or contribute) as shown below:

<MadCap:conditionalText MadCap:conditions="widget_A.WIFIonly" class="wifionly">

where wifionly is :

MadCap|conditionalText.wifionly
{
color: #339966;
}

in my review css.

I created a second css for final publication which has this for wifionly

MadCap|conditionalText.wifionly
{

}

This way the default color shows up for the text (almost always black).

What I was looking for is a way to associate the class with the condition without having to resort to global grep searching/replacing or scripts.


Wayne
i-tietz
Propellus Maximus
Posts: 1219
Joined: Wed Oct 24, 2007 4:13 am
Location: Fürth, Germany

Re: Automatic Styles in Condition Tags?

Post by i-tietz »

wbrisett wrote:What I was looking for is a way to associate the class with the condition without having to resort to global grep searching/replacing or scripts.
For online output you could insert a script into the masterpage that does that find and replace each time when a document is loaded (onload).

BUT:
I don't know whether that works for PDF output, since you need a page layout for it. And I don't know, how much javascript the PDF-making-engine can interpret ...
Inge____________________________
"I need input! - Have you got input?"
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Automatic Styles in Condition Tags?

Post by LTinker68 »

wbrisett wrote:What I was looking for is a way to associate the class with the condition without having to resort to global grep searching/replacing or scripts.
No, this can't be done natively, although I think others have mentioned a similar need. You can submit a feature request at http://www.madcapsoftware.com/bugs/submit.aspx asking for that ability.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
wbrisett
Sr. Propeller Head
Posts: 216
Joined: Mon Oct 05, 2009 3:29 pm
Location: Austin, TX

Re: Automatic Styles in Condition Tags?

Post by wbrisett »

Thanks. I did add a feature request this morning after I resolved how I was going to do it temporarily.

Wayne
owilkes
Propeller Head
Posts: 68
Joined: Wed Apr 20, 2011 10:01 am
Location: London

Re: Automatic Styles in Condition Tags?

Post by owilkes »

Sort-of-related - don't know if this will help, but it fitted our requirement -

one of the departments wanted a 'flag' on any page which had a particular condition text. We used this code for our master page (its all in the script):

<?xml version="1.0" encoding="utf-8"?>
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="265" MadCap:lastWidth="956">
<head>
</head>
<body>
<MadCap:breadcrumbsProxy />
<MadCap:dropDown>
<MadCap:dropDownHead>
<MadCap:dropDownHotspot>Related Information</MadCap:dropDownHotspot>
<p id="release" style="color: red;font-weight: bold;text-align: right;font-size: 48pt;" />
</MadCap:dropDownHead>
<MadCap:dropDownBody>
<MadCap:relationshipsProxy />
</MadCap:dropDownBody>
</MadCap:dropDown>
<MadCap:bodyProxy />
<p>
<script type="text/javascript">/*<![CDATA[*/
document.onclick = changeText();
function changeText(){
var checktag = document.getElementsByTagName("*");
for (var i = 0; i < checktag.length; i++){
if(checktag.getAttribute('MadCap:conditions')=="<CONDITION TEXT RECORD>.<CONDITION TAG>")
{
//alert(checktag.getAttribute('MadCap:conditions'));
document.getElementById('release').innerHTML = "*WHATEVER MESSAGE YOU WANT*";
}
}




}
/*]]>*/</script>
</p>
</body>
</html>

Any page which has <CONDITION TEXT RECORD>.<CONDITION TAG> somewhere in it (the whole topic, or a part of the topic) will have "WHATEVER MESSAGE YOU WANT" appearing on that page - obviously, you can then control how it appears through the master page.

HTH
markmetcalfemm
Propeller Head
Posts: 14
Joined: Fri May 18, 2012 8:48 am

Re: Automatic Styles in Condition Tags?

Post by markmetcalfemm »

I think I may have a solution without going into the CSS. (I tried the CSS first without success.)

You will need a UNIQUE conditional string to pull this off. For example, we have our version conditions in a separate condition file called Version_Conditions, as opposed to Target_Conditions, and Audience_Conditions.

Obligatory WARNINGS
Before you try ANY global find and replace operation, be absolutely sure that you are finding and replacing a UNIQUE string, or you may create a mess. Also, (and perhaps more importantly), backup your files (if you're not using source control) BEFORE proceeding. You should do this procedure ONLY before sending your material to review (and remove it before you add new information, because it is best when you can apply the highlighting all at once). I tried this out on a sample project before implementing this on a release project. USE AT YOUR OWN RISK (and post a reply if you can make it better or easier).

The following procedure finds a specific type of user-specified condition and adds a yellow highlight (background color) to the conditionalized text, to help reviewers easily find the change information in the output format.

1. Open a topic file that has conditions in it.

2. Go to Text Editor (HTML view) mode.

3. Open Find and Replace with Ctrl/F.

4. Type in Find What:

Code: Select all

MadCap:conditions="Version_Conditions.New material for next release"
5. Type in Replace With:

Code: Select all

style="background-color: #ffff00;" MadCap:conditions="Version_Conditions.New material for next release"
  • NOTE This Find-and-Replace should be easy to reverse if your string is unique. Be careful because you can easily search and replace the same file and wind up with some doubles like this:

    Code: Select all

    style="background-color: #ffff00;" style="background-color: #ffff00;" MadCap:conditions="Version_Conditions.New material for next release"
    If this happens, the string is unique enough to globally replace the incorrect double string with a correct single string.
  • CAUTION If you have another style reference in a tag - for example, style="margin-left: 3px;" and
    style="background-color: #ffff00;" - you will get an error when you build: (Internal error: Object reference not set to an instance of an object) and you will have to open each changed file to find out which files do not like the HTML (and then Flare will tell you which line it is on). You can manually resolve this by merging the 2 style parameters into 1, but you also may have to manually remove this afterward. (It should be safe enough to simply remove all style="background-color: #ffff00;" as long as you know that you do not have any other yellow background code in your files that you want to keep.)

    Also, make sure the find-and-replace operation does NOT add the style parameter to the <html> tag at the beginning of your topic file (which indicates you have the condition on the file itself). When you choose Find Next and it jumps to another file, if the first-found condition is NOT in the <html> tag, then you can click Replace All for every instance in that file and proceed to the next one. If your condition is found in the <html> tag, replace the items one at a time in that file. Even if this creates a semi-automated way to highlight your versioned text, you can remove the highlights in a single global replace operation.
6. Click Replace (to try it on one item) Replace All (to try it on one file) or Replace in All Files (if you're brave and confident, but you may be debugging a little).

7. Build your target and review the output. The conditional text should be highlighted in yellow - easy to spot!

To remove the highlighting when you are ready to publish, globally find and replace to reverse the process:

Find:

Code: Select all

style="background-color: #ffff00;" MadCap:conditions="Version_Conditions.New material for next release"
Replace:

Code: Select all

MadCap:conditions="Version_Conditions.New material for next release"
Or (again) just remove all the yellow background from your files:

Code: Select all

style="background-color: #ffff00;"
.

Good luck!
Post Reply