Output Types

An output type is a means of describing how a page or template should be rendered, based on the request type. We use output types to set defaults for what the web rendering should look like, but we can also use them to serve different feature templates adaptively. It's also often used to produce a Google AMP or RSS version of a page or template.

How does it work?

When PageBuilder encounters a request, such as http://tronc-sandbox.origin.arcpublishing.com/style/pets/la-hm-ellen-degeneres-cats-20170821-story.html, it assumes a default output type and requests the feature templates associated with the default option. However, we can also tell PageBuilder to render alternate templates, by specifying ?outputType= at the end of a request. For example, consider an AMP request to the same URL, made by appending ?outputType=amp to the end of the path: http://tronc-sandbox.origin.arcpublishing.com/style/pets/la-hm-ellen-degeneres-cats-20170821-story.html?outputType=amp. The page now renders AMP-compliant versions of the same features.

We can also use output types to control which versions of resources to use (such as inline styles added directly in the head vs calling external stylesheets) for performance and load testing or which versions of a feature template to load (XML output vs standard markup).

In production, some partners may choose to proxy their paths to a more-standard URL that does not have ?outputType= appended on the end. For example, an AMP path may be redirected at the CDN level from /2018/01/02/new-things-this-year/?outputType=amp to /2018/01/02/amp/new-things-this-year/.

How is it set up?

Each output type is defined in a JSON file in the output-types directory. The name of the file is the name of the output type with .json appended. For example, the default output type is stored in the JSON file default.json.

The output type allows us to specify which resources or versions of files to use for a particular request. The following fields are required in the JSON:

  • id — the name of the output type
  • headTemplate — relative path to the head file located in the inc directory
  • footTemplate — relative path to the foot file located in the inc directory
  • contentType — usually text/html but could also be xml, json etc
  • contentEncoding — Usually UTF-8
  • columnConfig — An object containing information about the configurable viewports and the maximum number of columns for the grid

Additionally, optional fields add a further layer of control over the rendering. Those fields include:

  • featureWrapper — relative path to the feature wrapper file located in the inc directory; omit if you do not wish to use a feature wrapper in this output type
  • resources — links/paths to any global styles or JavaScript files to request for the output type
  • pageResources — array of strings describing which files PageBuilder should include from feature-level directories
  • wrap — boolean value to determine whether or not to include a feature wrapper. Default value is true so this field is only required if you wish to omit the feature wrapper.

results matching ""

    No results matching ""