This article describes a feature available in Platinum and higher subscription plans.

When editing some fields a Template drop-down is available to choose from pre-set templates.  In the Title field these allow you to choose to display the title as a H3, H2 and so forth. 

Click the Pencil icon next to the drop down to launch the Template Editor.  This code editor provides access to the Handlebars template used to display the selected field.  The editor is pre-populated with the code in the selected template.  You can not modify the system-provided templates, but you can copy them and create our own custom templates. 

To make your own custom template, provide a Template Name, make any code changes and click Save.  

A common use of the Template Editor is to introduce conditional logic into the output.  Examples include: 

  • If the phone field is empty, display a default phone number
  • If the result is in the Gold category, display a link to their Website and a direct phone number
  • If the result has the type = Person display a link to their Biography
  • If the result has type = Dealer, display only categories in the Dealer group
  • If the result has a description longer than 100 characters, display a link to the detail page.

And so forth.  The above examples all illustrate field-level logic.  The logic itself can involve any attribute of the result, so the Title template can check if the result has an image provided, for example.

The field template is passed the location object.  This allows for any result fields to be displayed as {{ fieldname }}.  The exact list of fields varies by each customer, but you can see each field under Data > Fields. Field names with spaces are reduced to their "safe" representation, which can be viewed under Data > Fields > Field Name > Field Details and the Template Markup shows the proper representation.

Most templates already have some Handlebars logic in them.  The first in the screenshot above shows the system checking to see if the Title field has a value, and if it does, output the Title and related markup, otherwise, it does nothing.

{{#if title }}
...
{{/if}}


Did this answer your question?