Locomotive allows you to create content types without imposing a specific pre-built structure. No SQL knowledge is required here.
Your content types can then be used directly in your Liquid templates.
Before further reading, make sure you created a site with Wagon.
Wagon provides you the generate command to help you to create the YAML file describing your content type.
cd ~/workspace/my_first_site wagon generate content_type events title:string description:text event_date:date
It will generate 2 files:
The first one contains the content_type declaration, the second contains sample data so that you can test your site with fake data. Some random data have been added.
Use plural for your content type names.
Examples: posts, articles, photos, success_stories, ...etc.
The available field types are
string, text, file, select, boolean, date, date_time, tags, integer, float, belongs_to, has_many, many_to_many.
It is strongly advised to declare a string field type as the first entry even if it's not used.
Here are the properties you can use on app/content_types/*.yml files. All the content types should be plural filenames.
Example of an Article content type:
name: Articles description: Just a simple blog module order_by: posted_at order_direction: desc slug: articles label_field_name: title fields: - title: label: Title type: string hint: The title of the article - posted_at: label: Posted at type: date hint: The date when the article has been or will be posted. - body: label: Body type: text text_formatting: html hint: The body of the article
Public name of the content type. Use plural.
Internal name of the content type. Use plural and lower case, no space.
Explanation displayed in the backoffice.
Field slug. Default field slug (generally title), it must be a string field. It is advised to not use relationship fields as it might cause issues with public entry submissions.
Any field slug or 'manually' or 'created_at'. Changes the order of content entries in backoffice and content entries.
'asc' or 'desc'
Field slug. Display entries grouped by a given field in the backoffice.
Note: Currently only works with select field types.
Slug of the field used as to organize content entries as a tree (WIP)
Activate public 'create' API (e.g for a contact form)
Array of emails to be notified of new entries made with the public API. Works only in the Engine, not with Wagon.
Title used as the subject in the notification email sent when a new content entry has been created
Control the display of the content type in the back-office. Possible values:
By default, the back-office displays the _label property (see label_field_name) of the content entry. This can be modified by writing your own Liquid template.
Array of slugs
Enable the search bar in the back-office. The array must contain a list of fields' slugs that will be checked for matching with user inputs.
List of fields whose structure is described below
The minimal structure:
field_slug: type: <type> option: value
Required. Label for the backoffice
Displays a hint in the backoffice.
Default false. Makes this field localized: each language will have a different value.
Rearrange your model fields in groups/tabs in the back-office. Do not use spaces in the string. (Underscores will be rendered as spaces in the Back Office, e.g. my_group will be displayed as MY GROUP).
Standard string field
No option, get the url with
Integer field. No option.
Float field. No option.
Date field. No option.
DateTime field. No option.
true or false field. No option.
Tags field. No option.
Declare a one-way relationship between two content types.
Example: product belongs to a category, field 'category' in products.yml:
Declare a recursive relationship between two content types.
Example: category has many products (field 'products' in categories.yml):
Notice the plurals and singulars.
Declare a many-to-many relationship between two content types.
Example: products has and belongs to many categories. In products.yml:
There are a number of protected words that cannot be used in content_type slugs or fields. They are:
Updated 18 days ago