Open navClose nav

Sortable List Field

https://res.cloudinary.com/forestry-demo/image/fetch/c_limit,dpr_auto,f_auto,q_80,w_640/https://forestry.io/uploads/2018/01/sortable-list-preview.png

A list of values with drag & drop reordering.

Options

  • General
    • Label — the human-friendly label shown above the input field in the editor.
    • Name — the key stored in your content’s front matter, used to access it in your templates.
    • Description — a human friendly description of what the field does and/or instructions for your editors.
    • Hidden — hides the field in the editor, but allows developers to set default values or maintain the field for legacy purposes.
  • Widget
    • Text/Select — toggles the sortable list to allow text input, or to restrict options to a select field
  • Validation
    • Minimum — the lowest number of items that must be added to this field.
    • Maximum — the highest number of items that can be added to this field.

Templating

You can access this field in your templates using the field’s name:

Hugo

<p>{{ delimit .Params.ingredients ", " }}</p>

Easily display a comma delimited string using the delimit filter

<h2>Ingredients:</h2>
<ul>
{{ range .Params.ingredients }}
  <li>{{ . }}</li>
{{ end }}
</ul> 

Jekyll

<p>{{ page.ingredients | array_to_sentence_string }}</p>

Easily display a comma delimited string using the array_to_sentence_string filter

<h2>Ingredients:</h2>
<ul>
  {% for ingredient in page.ingredients %}
    <li>{{ ingredient }}</li>
  {% endfor %}
</ul>

Config Files

You can configure this field in Front Matter Template Config Files as follows:

type: list
name: [String]
label: [String]
description: [String]
hidden: [true|false]
default:
- [String]
config:
  use_select: [true|false]

Example

type: select
name: ingredients
label: Ingredients
description: Provide ingredients for this recipe
hidden: false
default:
- 1 cup water
config:
    use_select: [false]

See the select field documentation for configuring the select when config.use_select is set to true


Last updated on December 31, 2017