Support and Documentation

Style selection

A theme's configuration file _config.json associates templates with content types for a given theme and context. You can override these assignments using resource bundles.

Default style

The key _template in a Styleguide data file assigns a template to the data file, as in the following example.

Example 85. Assigning default ftyle
{
  "_template": "/path/to/AuthorPage.hbs"
}


Referring to the previous snippet, when a visitor retrieves an author's page, Brightspot looks up the template AuthorPage.hbs, populates the placeholders with retrieved data, and returns the HTML code.

You can override the assignment between a data file and template using a resource bundle. The following example describes how to override the default template for an author's bio page.

Step 1: Determine the assigned template

  1. Open the data file that contains template assignment you want to override.

  2. Note the template specified by the key _template.

Referring to the snippet Assigning default ftyle, the assigned template is /path/to/AuthorPage.hbs.

Step 2: Identify overriding templates

Create or locate the template you want to use as the default override.

Example 86. Original template (AuthorPage.hbs)
{{#element "name"}}
    <h1>{{this}}</h1>
{{/element}}


Example 87. Overriding template (AuthorPageNew.hbs)
{{#element "name"}}
    <h1>{{this}}</h1>
    <h1>Writer Emeritus</h1>
{{/element}}


The snippet Overriding template (AuthorPageNew.hbs) adds a byline Writer Emeritus under the author's name.

Step 3: Identify overriding data files

Create or locate the data files that use the template you identified in Step 2. For information about creating a data file, see Populating the Styleguide preview.

Step 4: Declare overriding template

  1. Create or open a properties file as described in Creating properties files.

  2. Add a line in the properties file similar to the following example:

    /path/to/AuthorPage.hbs/defaultTemplate=/path/to/AuthorPageNew.hbs
    

In the previous snippet—

  • The left side of the assignment contains the template you determined from Step 1. The literal /defaultTemplate is mandatory.

  • The right side of the assignment is the file you identified in Step 2.

Step 5: Register templates

Register the overriding template in the styles member of the theme's configuration file _config.json.

{
  "styles": {
    "/core/author/AuthorPage.hbs": { 1
      "example": "/author/AuthorPage.json", 2
      "templates": [{ 3
          "displayName": "Writer Emeritus",
          "template": "/core/author/AuthorPageNew.hbs"
        }
      ]
    }
  }
}

1

Assigned template you determined in Step 1.

2

Declares the data file you identified in Step 3.

3

Registers the overriding template you identified in Step 2.

Step 6: Rebuild and upgrade theme

Rebuild the theme and then install it as a new release. For details, see Upgrading a theme to new release.

Author page with assigned template
Figure 234. Author page with assigned template


Author page with overriding template
Figure 235. Author page with overriding template


Restricting available styles

The key styles in a theme's configuration file _config.json assigns available styles to a given template, as in the following example.

You can override the styles available to a given content type using a resource bundle. In most use cases, you limit the available styles declared in _config.json. The following example describes how to limit the available styles for an author's bio page.

Available templates from configuration file
Figure 236. Available templates from configuration file


Available templates from resources bundle
Figure 237. Available templates from resources bundle