Result Folding Tutorial
In this case, you will be folding Vimeo video items of a Generic REST API source under the album items to which they belong (see Generic REST API Source Tutorial).
The final result should look as follows.
Step 0 - Requirements
The items involved in the result folding must have appropriate values in the required fields so that Coveo knows how to organize each item with regards to the others (see Understanding Result Folding).
In this tutorial, you decide to use the item URI as a unique identifier, and the album URI as the collection field value. Your fields are therefore configured as follows (see Generic REST API Source Tutorial):
|Collection field||@foldingalbum||Album URI|
|Item identification field||@foldingid||Video URI|
|Parent item identifier field||@foldingparentalbum||Album URI|
In this tutorial, the folding fields all start with
folding to make them easily identifiable and to ensure that they appear together when listed in alphabetical order. This is only for convenience purposes and not a field name requirement.
Step 1 - Add a Folding Component
Add a Folding component (see Add a UI Settings Component).
In the Folding dialog, in the Field box, select your collection field, which is
@foldingalbum, and then click OK (see Step 0 - Requirements).
In the Interface Editor UI Settings pane named after your folding collection field, in the Child field box, select your item identification field, i.e.,
In the Parent field box, select your parent item identifier field,
Step 2 - Add a Folded Result Template
Edit the default result template layout (see Edit template grid). In this case, you could reproduce the following layout:
Optionally, if you want the search result icon to be different, edit this component while in the template layout (see Edit a Component). You can choose another icon in the Value menu or click the Use small icon to make it smaller.
Step 3 - Add a Parent Result Template
Once you added a result template for folded items, create a result template for their parent items. If you want to keep this template very similar to the Default template, which applies to items that are not involved in folding, you can simply add the Result Folding component to the parent item template.
Edit the default result template layout to add the Result Folding component and make any other optional modification (see Edit template grid). You could reproduce the following layout:
Step 4 - Order Your Result Templates
The order in which the templates are listed matters. For every result, Coveo checks whether the conditions of the template at the top of the list are met. If the result meets them all, it is displayed using this template. If the result does not meet all of the template conditions, Coveo checks whether the search results meets the conditions of the second template, and so on. You must therefore order your templates so that all templates that have conditions are above the Default template, which by default does not have any. As a result, search results not meeting the conditions of all preceding templates will be displayed with the Default template.
In this case, your result template list could be the following:
|Result template name||Condition field||Condition value||Comment|
|Video template||@filetype||Video||Video results are displayed using this template.|
|User template||@filetype||User||User results are displayed using this template.|
|Album template||@filetype||Album||Contains a Result Folding component using the
|Folding template||@itemtype||Video||Videos displayed as folded items under an album search result are displayed using this template.|
|Default||N/A||N/A||Any search result that is not a video, an album, or a user is displayed using this template.|