Snippet Condition in PDF and HTML

This forum is for all Flare issues not related to any of the other categories.
Post Reply
Zauberlehrling
Propeller Head
Posts: 43
Joined: Thu Sep 15, 2022 7:40 am

Snippet Condition in PDF and HTML

Post by Zauberlehrling »

Happy New Year everyone.

I have a little issue. I want to show a certain information in PDF but not in HTML, but it does not show the way it's planned.
I made screenshots of all my steps so you can see what I did and maybe can follow up where the issue is. I can't see where it is.

1. In Flare I created a snippet with the following text and condition.
Flare_Snippet.PNG
2. Then I placed the snippet into the Topic. The first is with a snippet condition to show it only for one specific Document. The second without that snippet condition.
In_Topic_with_Snippet_Condition.PNG
In_Topic_without_Snippet_Condition.PNG
The conditions for PDF are
- PrintOnly Include
- ScreenOnly Exclude

The condition for HTML are
- PrintOnly Exclude
- ScreenOnly Include

The result is the following. The first shows the PDF output, the second shows the HTML output.
Print_Output.PNG
Online_Output.PNG
Since I was concentrated on the HTML output I overlooked that it didn't show correctly in the PDF output. I just noticed by accident, because I wanted to replicate it for a new document.

Can anyone see where I made the mistake?
Thank you in advance.
You do not have the required permissions to view the files attached to this post.
Zauberlehrling
Propeller Head
Posts: 43
Joined: Thu Sep 15, 2022 7:40 am

Re: Snippet Condition in PDF and HTML

Post by Zauberlehrling »

I think I know what the issue is.
The PDF has a snippet condition on the topic, but the HTML hasn't one. It just has the condition to show Screen and hide Print.

But when thinking about it, why can I not have snippet condition on a conditioned snippet?
If someone could explain that would be much appreciated.

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

Re: Snippet Condition in PDF and HTML

Post by NorthEast »

(1) This isn't how you use snippet conditions.
As you have conditioned text that you want to exclude/include in separate target outputs, then you only need to set the conditions in the target Conditional Text tab. This will apply the conditions to everything in your target output (including content in snippets).

Do not set any Snippet Conditions in the topic properties or snippet properties. You would only use snippet conditions if a snippet contains conditional text that you want to exclude/include in separate topics (not separate targets) - for example, you want "ABC" to display in topic 1 and "DEF" to display in topic 2, where the topic are in the same target output.

(2) Also, you probably don't need to set Include for any conditions, as by default the condition is included in the output. In most cases you just need to set Exclude for the conditions you don't want. The Include setting is often misunderstood as it is actually used as an override. So if you have condition A and condition B on the same element, and set the conditions to A-Exclude and B-Include, the condition B will override condition A.
Zauberlehrling
Propeller Head
Posts: 43
Joined: Thu Sep 15, 2022 7:40 am

Re: Snippet Condition in PDF and HTML

Post by Zauberlehrling »

Thank you, I will try that and let you know about success or failure. :oops: 8)
Zauberlehrling
Propeller Head
Posts: 43
Joined: Thu Sep 15, 2022 7:40 am

Re: Snippet Condition in PDF and HTML

Post by Zauberlehrling »

I took the Snippet Condition off, see the result (Spoiler: it's a failure).
HTML_output.PNG
PDF_output.PNG
You do not have the required permissions to view the files attached to this post.
AlexFox
Sr. Propeller Head
Posts: 265
Joined: Thu Oct 19, 2017 1:56 am

Re: Snippet Condition in PDF and HTML

Post by AlexFox »

It's worth noting that conditional text is pretty blunt in its implementation, for example you can't exclude at a general level and then include at a more specific level.

Take the following example:

Code: Select all

        <div MadCap:conditions="Status.Draft">
            <p>Conditional Paragraph</p>
            <ul MadCap:conditions="Status.Review">
                <li>Conditional List Item 1</li>
                <li>Conditional List Item 2</li>
                <li MadCap:conditions="Status.Complete">Conditional List Item 3</li>
            </ul>
        </div>
In the XML editor this would appear as so:
conditional_div.png
If you had the following target settings:
conditional_target.png
The entire div and all child items will be removed from the output, including the li item with the "Complete" status, even though you explicitly specified that it should be included in the target.

I say this because you noted "The whole block has also a condition to be shown only for a certain area." so I suspect this is the issue.
You do not have the required permissions to view the files attached to this post.
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Snippet Condition in PDF and HTML

Post by NorthEast »

Zauberlehrling wrote: Wed Jan 08, 2025 9:04 am I took the Snippet Condition off, see the result (Spoiler: it's a failure).
Ok, but did you set conditions for each target on the target's Conditional Text tab?
You would need to set conditions as follows:

PDF target:
- ScreenOnly : Exclude

HTML target:
- PrintOnly : Exclude
Zauberlehrling
Propeller Head
Posts: 43
Joined: Thu Sep 15, 2022 7:40 am

Re: Snippet Condition in PDF and HTML

Post by Zauberlehrling »

Yes, I have doe all that. It did not work, but now it seems to be fine. Can't remember what happened.
I will have to do something similar in a couple of weeks and will try again.
Thanks for the moment, I might need to come back to that topic.
Post Reply