Example Templates

This page contains some simple examples of templates. There are more examples of default templates available at:

https://github.com/opentext-idol/find/tree/master/webapp/core/src/main/public/static/js/find/templates/app/page/search/default-custom-templates/

Simple Template

The following template is a simple search result template that displays a thumbnail image for documents that contain a thumbnail field. It also displays the document summary, the authors field, and a link to get similar documents.

<div>
    <h1><i class="{{icon}}"></i>{{title}}</h1>
    {{#hasField 'thumbnail'}}
       <img src="{{thumbnail}}"/>
    {{/hasField}}
    <p>{{{summary}}}</p>
    <p>Author: {{getFieldValue "authors"}}</p>
    <a href="{{similarDocumentsUrl}}">See similar documents</a>
</div>

Multiple Format Styles

The following example shows some different ways of formatting the authors field in your results.

<p>Authors: {{getFieldValues "authors"}}</p>
<p>Only the first author: {{getFieldValue "authors"}}</p>
<p>
    Formatting all authors as badges:
    
    {{#getFieldValues "authors" ellipsis='<font color="gray">...</font>'}}
        <span class="badge"> {{ this }} </span>
    {{else}}
        (no authors)
    {{/getFieldValues}}
</p>
<p>
    Only showing the first author as a single badge:

    {{#getFieldValue "authors"}}
        <span class="badge"> {{ this }} </span>
    {{else}}
        (no author)
    {{/getFieldValue}}
</p>
<p>
    Only showing the first two authors, the rest as ellipsis:

    {{#getFieldValues "authors" max=2 ellipsis='<font color="gray">...</font>'}}
        <span class="badge"> {{ this }} </span>
    {{else}}
        (no authors)
    {{/getFieldValues}}
</p>

For example, if you have the following IDOL document:

#DREREFERENCE format-test
#DRETITLE Formatting test
#DREFIELD DOCUMENT_METADATA_AUTHOR_STRING="Alice"
#DREFIELD DOCUMENT_METADATA_AUTHOR_STRING="Bob"
#DREFIELD DOCUMENT_METADATA_AUTHOR_STRING="Charlie"
#DRECONTENT
Written by Alice, Bob and Charlie
#DREENDDOC
#DREENDDATANOOP

and a complementary configuration in the fieldsinfo section of the Find config.json file:

"authors": {
   "names": [
      "AU_DOCUMENT_METADATA_AUTHOR_STRING",
      "DOCUMENT_METADATA_AUTHOR_STRING"
   ]
}

For this example template and document, Find displays the following:

For a document without any authors, Find displays the following: