Using Knowledge and Promotion Proxies in Search Results

We started this tutorial by adding micro content to search results with featured snippets and the Knowledge Panel. In this lesson, we'll see how to use the Knowledge and Promotion proxies in search results too.

How to Display Randomized Micro Content in Search Results

If you want to include a Knowledge or Promotion proxy in search results (or any other extra content), you need to first create a special topic that will be used to display it. This topic must include a Search Results proxy. Beyond that, you can add whatever you like. In our case, we'll add a Promotion proxy and put it in a responsive layout, similar to what we did in our template page.

  1. In the Content Explorer, add a new topic named Search-Results at the root level.

  2. Delete all the text in that topic so that you only have an empty paragraph.

  3. On the Home ribbon, click Responsive Layout to open that window pane on the right.

  4. From the Styles drop-down in that window pane, select div.Tiles-8-4 (the same one we used earlier in our template page). Then, select Insert Row.

  5. Delete the empty paragraph, and select the Cell 1 text, which will be removed once you insert your first proxy.

  6. In the Insert ribbon, select Proxy > Search Results Proxy.

  7. Click OK. The proxy is added to the first cell of the responsive layout.

  8. Select the Cell 2 text.

  9. In the Insert ribbon, select Proxy > Promotion Proxy.

  10. In the What micro content to include field, select Specific micro content files. Then, in the field under that, select Resources/MicroContent/Promotions.flmco.

  11. In the How micro content is included field, select All micro content.

  12. Click OK.

  13. Click Save the active file. to save your work.

  14. Build the First-HTML5-Target file, and when it is finished, open the output.

  15. Search for Sit. Notice that the results all seem to be compressed to the left side of the page, while a lot of white space remains on the right.

    The reason for this is that the new Search-Results topic is using the default template page (Other-Topics), which we have adjusted to leave room on the right side for micro content. That's fine for most of our regular topics, but we don't want that for our search results. So the easiest way to solve this is to create a new template page just for the search results. Let's do that now.

  16. In the Content Explorer, expand the Resources folder. Right-click the TemplatePages folder, hover over New, and select Template Page.

  17. In the Add File dialog, select TemplatePage.flmsp as the template file, and in the File Name field enter Search-Results.

  18. Click Add.

  19. In the new template page that opens, delete all of the proxies except for "topic body proxy" (you can right-click each proxy bar and select Delete). When finished, the template page should look like this.

  20. Click Save the active file. to save your work.

  21. In the Content Explorer, right-click the Search-Results.htm topic and select Properties.

  22. In the dialog, select the Topic Properties tab, and in the Template Page drop-down select Search-Results (the name of the new template page).

  23. Click OK.

  24. Rebuild and view the output.

  25. Search for Sit. Now the results take up the entire width of the page. In this example, the Boxer rescue micro content is shown on the right. The Knowledge Panel holding the micro content steps on the left still might be a little narrow, but we can fix that in the skin later.

  26. If you were to perform another search or even refresh the page, the micro content on the right will eventually display the Beagle rescue content. This illustrates that the micro content in the search results is randomized.

How to Display FAQs Using a Knowledge Proxy in Search Results

It might seem strange to use a Knowledge proxy to display FAQs in the search results when an FAQ proxy is available. But that's what we're going to do now. The reason is that the FAQ proxy content is compiled when the target is generated (i.e., it's static), whereas the Knowledge proxy content is compiled when a search is performed in the output (i.e., it's dynamic). So for regular topics, it's fine to use an FAQ proxy, but for search results in the output we want to use the Knowledge proxy because we want the results to be targeted based on the search keywords, rather than displaying the same FAQs every time.

  1. Open the Search-Results.htm topic.

  2. Adding a new proxy above or below our Promotion proxy can be a bit tricky when the proxy is inserted into a responsive layout, like ours is. That's why it's sometimes a good idea to create extra empty paragraphs when you first begin working in a cell of a new responsive layout, as we did earlier in this tutorial. We want to add a new Knowledge proxy below the Promotion proxy in the responsive layout, but we don't have any empty paragraphs in our cell, so we need another solution. One way to handle this is to first insert the proxy in the topic (outside of the responsive layout) and then switch to the Text Editor to move it where we want. To begin, click the Promotion Proxy bar in the topic, and press the down arrow on your keyboard so that a horizontal cursor flashes below the responsive layout (under the Search Results Proxy bar). You should also see that the "body" structure bar is highlighted, indicating that our next action will take place outside of the responsive layout (represented by the "div" structure bar).

  3. Press ENTER.

  4. In the Insert ribbon, select Proxy > Knowledge Proxy.

  5. Let's give this content a title. In the Proxy Title field, enter FAQs.

  6. In the What micro content to include field, select Specific micro content files. In the field under that, select Resources/MicroContent/FAQs.flmco.

  7. In the How micro content is included field, select Search query.

  8. Let's say we want to be able to display more than one FAQ if matches exist, but we never want to show more than four of them. So in the Limit number of results field, enter 4.

  9. Click OK. The proxy is added to the topic, but it's not in the responsive layout, where we want it.

  10. Click the Text Editor tab at the bottom of the XML Editor, then highlight the markup shown in the following image.

  11. Press CTRL+X on your keyboard to cut it.

  12. Place your cursor after the tag </MadCap:promotionProxy>, and press ENTER to create a new empty line.

  13. Press CTRL+V on your keyboard to paste the markup at that location.

  14. Click the XML Editor tab at the bottom. Notice the Knowledge proxy is now located within the responsive layout under the Promotion proxy.

  15. Click Save the active file. to save your work.

  16. Rebuild and view the output.

  17. Search for Dog. Notice the new micro content on the right side of the page, under the dog rescue promotion content. You'll need to scroll down the page, but you will see that there are three FAQ pieces of micro content that matched the search and are displayed.

    You might be thinking, "Those don't look like FAQs though." That's something that we can fix in the next lesson when we look at skins.