Articles

04/072023

Using content boxes in MadCap Flare: Tips and tricks

In Part One, you learned how to create content boxes for HTML5 and PDF outputs in Flare. In Part Two, we’ll explain some strategies for using content boxes efficiently in MadCap Flare.

Adding a content box

There are a few different ways to add a content box to the topic you’re working on. To use these methods, create a topic in your project that contains copies of all the styles you use in your document, including the content boxes. You can call this document template.htm or something similar.

Copying the code

  1. Go to template.htm.
  2. Copy the entire div of the content box you want to use. You can do this by clicking the div selector on the left side of the XML editor and pressing Ctrl+C.
    A Danger box in the Flare XML editor. The div is selected and its contents are highlighted.
  3. Paste it to the page you’re working on, and modify the content.

Tip: The spacing in the box, like the indentation of p.ContentBox, may not appear correctly in the XML editor. To check that the spacing is correct, build and view the target.

Using a snippet

  1. Go to template.htm.
  2. Hover over the div of the box you want to use. Right-click and select Create Snippet.

    Tip: Be sure that you are selecting the whole div and not the text inside the box.

  3. In the Create Snippet window:
    1. Give your snippet a relevant name and put it in the appropriate folder.
    2. Uncheck Replace Source Content with the New Snippet.
    3. Click Create.
      The Create Snippet window in Flare showing the Danger box. You can edit the filename and folder, as well as see what the snippet looks like. There is an unchecked box at the bottom of the window saying, "Replace source content with the new snippet".
  4. In the topic you’re working on, go to Insert > Snippet in the top ribbon. Choose the snippet of the content box you want to use and click OK.
    1. If you need to add more content boxes of the same type elsewhere, you can pin the content box snippet in the Insert Snippet Link window by hovering over the snippet’s line and clicking the thumbtack icon that appears.
      The thumbtack icon appearing next to the snippet.
  5. Right-click the div and select Convert to text.
    The “Convert to text” option for snippets in Flare.
  6. Modify the content in the box.

Putting new content in a box

One way of putting new content in a box is to add the content to the Flare topic before wrapping it in a div. This is a good strategy for boxes where the icon’s line height overlaps with the line height of a single line of text, which makes it difficult to  select in the XML editor.

To do so:

  1. Paste the content box you need using one of the methods described above.
  2. In a paragraph tag under the content box, add the content that you want to put in the box. Add any elements that you need, such as conditions, cross-references, and variables, in this step.
  3. Delete the existing text in the content box.
  4. On the left side of the editor, right-click the paragraph selector that your new content is in and click Move > Move Up.
  5. Change the paragraph style of text and images to p.ContentBox.

    Tip: Regular list styles should work in the box as long as they are preceded by p.ContentBox and the top padding property for list styles in div.ContentBox is set to 0.

  6. Repeat steps 4 and 5 for the rest of your content. If the p.ContentBox style uses negative top padding, use the p.ContentBox2 style as needed.A GIF showing how to wrap text in a content box div.

Editing inside the box

If you need to edit an existing content box, here are some ways to do that:

  • Click the div you want to edit. Then, change tabs to the Text Editor and edit the content there. The code of the div you clicked will already be highlighted. Make your edits in the Text Editor.
    The highlighted code of a Danger box in the Flare HTML editor.
  • To edit text, click inside the content box, press the down arrow on your keyboard, and then press the right arrow. This will put you on the correct line so you can edit text. To select text, hold down the Shift key while pressing the arrow key in the direction you want to select.

 

Well-formed content boxes can help you break your documentation into small chunks and highlight important information. With this article series, you’ll be able to create easy-to-use content boxes for your Flare projects.