Show Menu
TOPICS×

About Templates

You can use Templates to manage your presentation templates and transport templates.

About Templates

You can add, edit, copy, rename, or delete presentation templates and transport templates. When you click an existing template name in the Templates table, it is opened in an editor (or viewer) window where you can make your changes.
You can revert any changes you make to templates using the History feature from the template name's drop-down list in the Templates table.
You can reduce the page weight of a presentation template by checking the template's corresponding Minimize checkbox in the template table. By reducing the template's page weight, you dynamically minimize inline JavaScript and CSS. You also remove redundant whitespace in the HTML. Minimizing the page weight of your presentation template can help to deliver your search results faster.
You can preview the appearance of the minimized template by clicking the drop-down list next to the filename and then clicking Preview minimized . If you minimize the main presentation template, be sure that you remember to enable minimizing for included (with guided-include tag) templates because this option is not inheritable.
Even if you minimize a presentation template, you can still edit the "unminimized" version of the same template.
You can use the pre-search rules, post-search rules, and business rules to determine when to use one of your other presentation templates. It is common to have a rule such as "For every search, set the targeted template to xxxx". With such a rule in place, when you change the "Default" template in the Templates table, it appears to have no effect.

About presentation templates

Presentation templates are HTML templates that a customer sees when they are viewing the results of their search on your website.
In your presentation layer, you can have a single presentation template that presents the results of multiple searches from various sources. You can define as many presentation templates as you want and even define presentation templates that other templates share using include commands. The presentation template is where all of the Design components such as facets, menus, and breadcrumbs, come together. To display the various design components, you must use presentation template tags.
When you have more than one presentation template, you define under what conditions the various presentation templates are used. You can select which presentation template to use based on the incoming CGI parameters and cookies. Or, you can switch what presentation template you are using based on the outcome of a previous search.
When you use multiple presentation templates, be sure that you indicate which template that you want the search results to appear initially. You can do this using the Default column of the Templates table.

About transport templates

Transport templates can be either XML or JSON templates that pass data from the back-end search to the Guided Search presentation layer.
By default, your account is configured to use XML transport templates. However, if you prefer to use JSON to pass your data to Guided Search, contact Adobe Consulting who can assist you.
In your presentation layer, you can have a single presentation template that presents the results of multiple searches. Each search can use the same transport template or a custom transport template to pass the data to the presentation layer. Because the transport template is only used to pass data to the presentation layer, it must not have any HTML that is used to display the search results. The template uses transport template tags to pass the results of the search and results for populating the facets. Within these tags, standard search template tags are used to display the actual values.
XML Transport Template-specific tags
XML transport template tag
Description
<guided-xml></guided-xml>
These are the root XML tags that the presentation layer uses to detect what it must parse out of the transport template.
<general></general>
This set of tags surround search template tags that provide summary data based on the result set. Typically, these tags contain search tags for the total number of results, lowest result, and highest result. You can define any number of additional global fields that you want with the general-field tag.
Example
    <general>       <total><search-total /></total>       <lower><search-lower /></lower>       <upper><search-upper /></upper>       <general-field name="my_custom_field">Some global content</general-field>     </general>
<results></results>
This set of tags are wrapped around the search results, so that Guided Search knows where to look for them.
<result></result>
This set of tags are wrapped around each search result, so that Guided Search recognizes where the content for a single search result starts and ends.
Example
    <results>       <search-results>         <result>           <index><search-index /></index>           <loc><search-cdata><search-url length="500" /></search-cdata></loc>         </result>       </search-results>     </results>
<attribute-table name="tablename">
This tag lets you loop through each item in a multi-value list for a single result. Use the tag only within a result. Its primary purpose is to let you iterate over attributes belonging to a result field.
Example
      <results>         <search-results>           <result>             <index><search-index /></index>             <loc><search-url /></loc>             <title><search-title /></title>             <attribute-table name="downloads">               <field name="download_title"><search-display-field name="download_title" /></field>               <field name="download_link" delimiter="|"><search-display-field name="download_link" /></field>             </attribute-table>           </result>         </search-results>       </results>
<facets></facets>
This set of tags pass over the results that populate the facets.
<facet name="name"></facet>
Each facet must have its own facet tags where the name parameter matches the facet name. Search tags are used within the facet tags for the facet values.
Example
    <facets>       <facet name="brand">         <values><search-field-value-list name="brand" quotes="no" commas="yes" data="values" sortby="values" /></values>         <counts><search-field-value-list name="brand" quotes="no" commas="yes" data="counts" sortby="values" /></counts>       </facet>       <facet name="category">         <values><search-field-value-list name="category" quotes="no" commas="yes" data="values" sortby="values" /></values>         <counts><search-field-value-list name="category" quotes="no" commas="yes" data="counts" sortby="values" /></counts>       </facet>     </facets>
<suggestions></suggestions>
This set of tags wrap your Did You Mean suggestions so that Guided Search recognizes which XML nodes contain suggestions.
<suggestion></suggestion>
This set of tags wrap each Did You Mean suggestion.
Example
    <search-if-suggestions>       <suggestions>         <search-suggestions>           <suggestion>             <value><search-suggestion-text /></value>             <count><search-suggestion-result-count /></count>           </suggestion>         </search-suggestions>       </suggestions>     </search-if-suggestions>
JSON transport template-specific tags
Passing JSON versus XML from the search-engine is known to be faster because it is smaller payload and a faster parser. Use care, however, when you use JSON to ensure that what is output is strict JSON because the parser is not forgiving.
If you are new to JSON, you can use the following links and examples to help you get started:
Example JSON template
{ 
 "general": 
 { 
  "total" : "<search-total />", 
  "lower" : "<search-lower />", 
  "upper" : "<search-upper />", 
  "rbt-trigger-list" : "<search-rbta-trigger-id-list>", 
  "fields" :  
  [ 
   { 
    "name" : "seo_search_title", 
    "value" : "<search-include file="seo/seo_search_title.tpl" />" 
   }, 
   { 
    "name" : "seo_search_keywords", 
    "value" : "<search-include file="seo/seo_search_keywords.tpl" />" 
   } 
  ] 
 }, 
 
 <search-if-suggestions> 
 "suggestions": 
  [ 
  <search-suggestions> 
  { 
   "suggestion":"<search-suggestion-text />", 
   "count": "<search-suggestion-result-count>" 
  }<search-if-not-last-suggestion>,</search-if-not-last-suggestion> 
  </search-suggestions> 
 ], 
 </search-if-suggestions> 
 
 "facets" : 
 [ 
  { 
   "name" : "leveli", 
   "values" : [ <search-field-value-list name="leveli" quotes="yes" sortby="values" data="values" encoding="json"/>], 
   "counts" : [<search-field-value-list name="leveli" quotes="no" sortby="values" data="results" />] 
  }, 
  { 
   "name" :"levelii", 
   "values" : [<search-field-value-list name="levelii" quotes="yes" sortby="values" data="values" encoding="json"/>], 
   "counts" : [<search-field-value-list name="levelii" quotes="no" sortby="values" data="results" />] 
  }, 
  { 
   "name" : "brand", 
   "values" : [<search-field-value-list name="brand" quotes="yes" sortby="values" data="values" encoding="json"/>], 
   "counts" : [<search-field-value-list name="brand" quotes="no" sortby="values" data="results" />] 
  }, 
 ], 
 "results" : 
 [ 
  <search-results> 
  { 
   "fields" : 
   [ 
    { 
     "name" : "index", 
     "value" : "<search-index />" 
    }, 
    { 
     "name" : "loc", 
     "value" : "<search-display-field name="url" length="500" encoding="json"/>" 
    }, 
    { 
     "name" : "title", 
     "value" : "<search-display-field name="title" encoding="json"/>" 
    }, 
    { 
     "name" : "img_url_thumbnail", 
     "value" : "<search-display-field name="img_url_thumbnail" encoding="json"/>" 
    }, 
    { 
     "name" : "description", 
     "value" : "<search-display-field name="description" encoding="json"/>" 
    }, 
    { 
     "name" : "mdi", 
     "value" : "<SEARCH-RBTA-DISPLAY-MDI-FIELD>" 
    } 
   ] 
  }<search-if-not-last>,</search-if-not-last>  
  </search-results> 
 ] 
}

Example JSON result section with a results attribute table
{ 
 "results" : 
 [ 
  <search-results> 
  { 
   "fields" : 
   [ 
    { 
     "name" : "index", 
     "value" : "<search-index />" 
    }, 
    { 
     "name" : "loc", 
     "value" : "<search-display-field name="url" length="500" encoding="json"/>" 
    } 
   ], 
   "tables" : 
   [ 
    { 
     "name" : "downloads", 
     "fields" : 
     [ 
      { 
       "name" : "download_title", 
       "value" : <search-display-field name="download_title" encoding="json"/> 
      }, 
      { 
       "name" : "download_link", 
       "value" : <search-display-field name="download_link" encoding="json"/> 
      } 
     ] 
    } 
   ] 
  }<search-if-not-last>,</search-if-not-last>  
  </search-results> 
 ] 
}

Example JSON Facet section for a facet with associated fields
{ 
 facets" : 
 [ 
  { 
   "name" : "t1", 
   "values" : [<search-field-value-list name="t1" quotes="yes" commas="yes" data="values" sortby="values" encoding="json" />], 
   "counts" : [<search-field-value-list name="t1" quotes="yes" commas="yes" data="results" sortby="values" />], 
   "custom-fields" : 
   [ 
    { 
     "name" : "taxonmyId", 
     "value" : [<search-field-value-list name="tax1" quotes="yes" commas="yes" data="values" sortby="values" encoding="json" />] 
    } 
   ] 
  } 
 ] 
}

Example JSON Facet section for slotted facets
{ 
  "facets" : 
  [  
   { 
    "name" : "fvalue0", 
                  "dynamic" : 1, 
                  "display-names" : [<search-field-value-list name="fname0" quotes="yes" commas="yes" data="values" sortby="values" encoding="json" />], 
    "values" : [<search-field-value-list name="fvalue0" quotes="yes" commas="yes" data="values" sortby="values" encoding="json" />], 
    "counts" : [<search-field-value-list name="fvalue0" quotes="no" commas="yes" data="results" sortby="values" />] 
   } 
  ] 
} 


Adding a new presentation or transport template file

You can use Add Template to add presentation templates (.tmpl) or transport templates (.tpl) to the Templates page.
To add a new presentation or transport template file
  1. On the product menu, click Design > Templates .
  2. On the Templates page, click Add New Template .
  3. In the Add Template dialog box, set the options that you want.
    Option
    Description
    New file name
    Specifies the name of the template that you want to add. The proper file extension is automatically added to the file name, based on the template type you select. Presentation templates have a .tmpl file extension; Transport templates have a .tpl file extension.
    New template type
    Lets you choose a presentation or a transport template that you want to add. See About Templates .
  4. Click Add .
  5. (Optional) On the Templates page, do one of the following:

Editing a presentation or a transport template

You can use the Template Editor to view and edit the content of your presentation and transport template files.
You can edit and test your staged presentation and transport templates, while your website visitors continue to use the live versions of your templates. You test your staged template using the staged version of your search domain URL. For example, you can test your staged transport template by running a staged query ( sp_staged=1 ) with sp_t that is set to the name of your transport template. When you are satisfied with how the layout appears, you can use Push Live from within the template editor to push the template live. After the template is live, site visitors begin to use it.
Use the presentation template tag reference to learn how to hook up your presentation template to Guided Search components such as facets, breadcrumbs, and menus.
Use the transport template tag reference to learn more about the tags to use in transport templates.
To edit a presentation or a transport template
  1. On the product menu, click Design > Templates .
  2. On the Templates page, click a presentation or a transport template file name.
  3. On the Template Editor page, make the changes you want to the tags and coding.
    Be careful about the changes you make in the Template Editor; there is no Undo feature. If you make an undesired change and want to go back to the previous version of the file, you can click Cancel to return to the table of templates (assuming you did not save any of your changes up to that point). If you have already saved your changes, you can use History in the editor to revert those changes.
  4. (Optional) Click Insert Symbol to enter special characters and symbols that do not have corresponding keys on US English keyboards.
  5. Click Save Changes .
  6. (Optional) Do one of the following:
  7. Close the Template Editor page when you are finished; you are returned to the Templates page.

Copying a presentation or a transport template file

You can use Copy Template to save time by duplicating an existing Presentation template (.tmpl) or Transport template (.tpl) and add it to the Templates page.
You must change the template name, the template type, or both. If you make no changes, the template is not copied.
You must have a template already added to be able to copy a template.
To copy a presentation or a transport template file
  1. On the product menu, click Design > Templates .
  2. On the Templates page, in the drop-down list next to a template name that you want to copy, click Copy .
  3. In the Copy Template dialog box, set one or more of the options that you want.
  4. Click Copy .
  5. (Optional) Do one of the following:

Renaming a presentation or a transport template file

You can use Rename Template to change the name of an existing presentation template (.tmpl) or a transport template (.tpl).
You can also change the template type, if desired.
You must have a template already added to rename a template.
To rename a presentation or a transport template file
  1. On the product menu, click Design > Templates .
  2. On the Templates page, in the drop-down list next to a template name that you want to rename, click Rename .
  3. In the Rename Template dialog box, set one or more of the options that you want.
  4. Click Rename .
  5. (Optional) Do one of the following:

Deleting a presentation or a transport template file

You can use Delete Template to remove an existing presentation template (.tmpl) or a transport template (.tpl).
You may already have a corresponding version of the staged template that is pushed live. If so, be sure you push the deleted template live using Staging so that it is also deleted from the live environment. Or, you can use Push Live on the Templates page.
You must have a template already added to be able to delete a template.
To delete a presentation or a transport template file
  1. On the product menu, click Design > Templates .
  2. On the Templates page, in the drop-down list next to a template name that you want to delete, click Delete .
  3. In the Delete Template dialog box, click Delete.
  4. (Optional) Do one of the following:

Previewing the presentation template minimized

You can use Preview minimized to see what the reduced page weight of a presentation template would look like if you choose to minimize it.
If you minimize the main presentation template, be sure that you remember to enable minimizing for included (with guided-include tag) templates because this option is not inheritable.
You must have a template already added to preview the template minimized.
You can preview the XML code of a transport template file.
To preview the presentation template minimized
  1. On the product menu, click Design > Templates .
  2. On the Templates page, in the drop-down list next to a presentation template name, click Preview minimized .
    Use the Type column in the Templates table to sort the templates by Presentation and Transport.
  3. (Optional) On the Preview Minimized Template page, check Wrap lines to read the tags within the defined window.
  4. Click Close .
  5. (Optional) Do one of the following:

Reducing the page weight of a presentation template on your website

You can reduce the page weight of a presentation template by using the Minimize option in the template table.
By reducing the template's page weight, you dynamically minimize inline JavaScript and CSS. You also remove redundant whitespace in the HTML. Minimizing the page weight of your presentation template can help to deliver your search results faster.
You can also preview the appearance of the minimized presentation template by using Preview minimized .
To reduce the page weight of a presentation template on your website
  1. On the product menu, click Design > Templates .
  2. On the Templates page, under the Minimize column, check the box for one or more presentation template files that you want to push as minimize on your website.
    Use the Type column in the Templates table to sort the templates by Presentation and Transport.
  3. (Optional) Do one of the following:

Setting the default presentation template file to use on your website

When you have multiple presentation templates, you can indicate what template is initially be used to display search results.
You can use the pre-search rules, post-search rules, and business rules to determine when one of your other presentation templates should be used.
It is common to have a rule such as "For every search, set the targeted presentation template to xxxx." With such a rule in place, changing the "default" template on the Templates page will appear to have no effect.
To set the default presentation template file to use on your website
  1. On the product menu, click Design > Templates .
  2. On the Templates page, under the Default column, click the radio button to the corresponding presentation template file that you want to serve as the default.
    Use the Type column in the Templates table to sort the templates by Presentation and Transport.
  3. (Optional) Do one of the following:

Previewing the XML of a transport template file

You can use Preview to review the XML of a transport template that you have added.
You must have a transport template already added to preview the template's XML.
You can preview minimized presentation template files to view their reduced page weight.
To preview the XML of a transport template file
  1. On the product menu, click Design > Templates .
  2. On the Templates page, in the drop-down list next to a transport template name, click Preview .
    Use the Type column in the Templates table to sort the templates by Presentation and Transport.
  3. Close the viewing window and return to site search/merchandising.
  4. (Optional) Do one of the following: