TTWeb Basics 1. Introduction to Content Models

Terminology

The traveltripper.io UI doesn’t use the term “Model” anywhere. It simply groups all content (regardless of wheter it’s a page, content model, menu, or gallery) in the “Content” area of a draft. All of the types of content models are just listed by name along with other content types. For example, in the “Content” area of a site, you may see a menu that looks like:

  • Attractions
  • Galleries
  • Menus
  • Pages
  • Rooms

and in that list, only Attractions and Rooms are structured Content Models.

Overview

Content Models allow you to create structured content that can be accessed through Liquid tags or used to generate sets of pages. Content Models are the TTWeb version of jekyll collections. If you are not familar with collections, read Ben Balter’s article for the overview and the Jekyll docs for the details.

The structure of a Content Model is defined in JSON. Instances of a model can be managed in the TravelTripper.io user interface.

What Models Can Build

Models can be used to represent anything from developer documentation to blog articles. A model contains a set of named fields (such as images, text, and urls) and also references to other models. Developers can define fields, references, and add basic validation. CRUD forms are automatically generated in the TravelTripper.io UI for use by content editors based on these model definitions.

A simple example.

Before we dive into the complete set of options available for defining a model, lets look at an example. A simple news article can be created with the following JSON:

{
  "title": {
    "required": true
  },
  "url_friendly_name": {
    "type": "url_slug",
    "required": true
  },
  "contents": {
    "type": "text",
    "required": true,
    "instructions": "Write the content of your news article."
  }
}

This represents a model with 3 fields:

  • The title field, which is a string that is required in each instance (and will cause a validation error if the field is left blank).
  • The url_friendly_name, which is a “slugified” url that will be used when automatically generating pages for each news article.
  • The content field provides the user with instructions if they’re confused to the purpose of the field.
  • Note: DO NOT use the value content for a field name (use contents instead). content is a reserved variable in jekyll and if used in models will end up nesting the page generation.

Further Reading

Content Model Definitions

Content Model Instances