Linking snippets

This forum is for Single-Sourcing your Flare content to multiple outputs.
Post Reply
Corinna
Propeller Head
Posts: 17
Joined: Mon Mar 20, 2017 5:56 am

Linking snippets

Post by Corinna »

Much to my disappointment, I learned that linking snippets is not possible in Flare. I do, however, use a lot of snippets in my project - some of which need to be linked to each other. The snippets are re-used in multiple topics that are then published online and in a PDF.

My online project, which I had first set up without Flare (plain HTML written in Notepad++), simply uses relative links to IDs (<a href="#yourID">) - which works as long as the link target is on the same HTML page. This doesn't work for PDF though. Another problem is that I don't want bookmarks in my PDF TOC/bookmark pane (only TOC entries).

After some thinking and tweaking and testing, I have come up with a workaround using conditions and IDs/bookmarks that might help some of you, so I thought I'd share it here. It's a bit elaborate and requires careful tagging and a good overview of a project, but it's worth it given the time saved applying single-sourcing methods. This only works for smaller projects, I think. (A table to keep an overview of the snippet link relations is useful either way.)

Here's an outline of the workaround:
inter-snippet-links.png
I have achieved this by doing the following:
1.) Creating snippets as usual. (e.g.: a.flsnp, b.flsnp) No links yet.
2.) Creating the topics that will hold the snippets. (e.g.: x.html, y.html)
3.) Inserting snippets into topics as usual.
4.) (Optional - depends on bookmark setup): Creating a set of conditions for the following aspects: publication format (e.g. ScreenOnly, PrintOnly) and topics (x, y)
5.) Setting the snippet conditions for each topic (e.g.: x.html: include everything for x, exclude everything else; y.html: include everything for y, exclude everything else)
6.) Setting the conditions for targets (e.g. PDF target: PrintOnly, exclude ScreenOnly; online target: ScreenOnly, exclude PrintOnly)
7.) This step depends on a project's requirements, but it is essential to the workaround: The snippet to which you would like to link needs a bookmark. If you want to publish PDFs, the bookmark needs to sit outside the snippet (for online targets alone, the ID could also sit inside the snippet).
You may use a different bookmark setup (two bookmarks for each publication format, or use just one bookmark, or other variations. For technical reasons, my snippets already have their own ID for GUI integration, which I use as link targets for my online output and also for a snippet's bookmark ID). My link targets almost always sit in the same topic as the link. (It's a long reference list of field descriptions that are re-used for tooltips in various screens.)

Placing a bookmark before each snippet (important for PDF targets) and setting the bookmarks' condition to "format: PrintOnly" so that these bookmarks will not appear in online output (=optional/specific to my project - other solutions possible).

Code: Select all

<h1>Topic 1</h1>
<p>This is a topic.</p>

<a name="a1" MadCap:conditions="format.PrintOnly"></a>
<MadCap:snippetBlock src="../snippets/test/a.flsnp" />
		
<a name="b1" MadCap:conditions="format.PrintOnly"></a>
 <MadCap:snippetBlock src="../snippets/test/b.flsnp" />
8.) Setting the links and defining their conditions in each snippet that links to another snippet. Each topic reference gets its own link. The link needs to contain the full path to the bookmark, otherwise it won't work in PDF.

Code: Select all

<a href="../../test/x.htm#b1" MadCap:conditions="files.x">Snippet B</a> <!-- link to snippet B in topic X -->
<a href="../../test/y.htm#b1" MadCap:conditions="files.y">Snippet B</a> <!-- link to snippet B in topic Y -->

If a snippet links to a snippet in only one other topic, I don't need to specify any conditions:

Code: Select all

<a href="../../test/x.htm#b1">Snippet B</a> <!-- link to snippet B in topic X -->
9.) Deactivating the option to "Include non-TOC bookmarks in the bookmarks pane" in the 'PDF options' tab of the PDF target's properties so that the snippet-identifying bookmarks won't show in the PDF navigation.

Results:
Online (HTML)
This is what my topics look like after clicking the link (CSS for highlighting the activated target):
result-online.png
Print (PDF)
result-pdf.PNG
You do not have the required permissions to view the files attached to this post.
Post Reply