How-to library · Developer docs

How-to library

Task-shaped pages: a title that starts with a verb, the situation in a few lines, the steps, the working code in both engines, and why this way rather than another. Found from a search, done, and left.

Topic 8 how-tos

Content modelling

Decide between a custom field and a layout area Areas are for content an author composes on a record that has a layout; custom fields are for structured attributes on records that do not. Pages and posts take areas; people, menus, categories, tags and SEO settings take fields. Model a simple directory as a custom entity Sixty stores with an address, hours and a photo are a definition with a listing path, a record path, a handful of areas, tags for facets and a positioned or alphabetical listing. No PHP, two templates. Relate two custom entity records to each other A relationship definition is a typed link between definitions with a minimum and maximum. Read it forwards from the owning record's relationships, and backwards with a query on the owning side, never by walking inverse relationships. Build a parent and child record hierarchy A definition with a parent definition makes every record a child of one parent record: created from the parent, sharing its site, moving with it. Give the child its own record path, and walk getParent() and getChildren(). Render a custom entity listing and detail page The listing renders the definition's template with the records under the plural identifier plus _pagination; the detail renders the layout's template with the record under the identifier and as record. Both are 404 without a template. Give a record a second URL with a custom URL A custom URL is an extra address independent of the slug and the tree. Both addresses serve the record, links from the record switch to it, and it works as a prefix. Add a rewrite if the old address must go. Set up an approval workflow before publishing A workflow is steps and transitions assigned to a content type or one record. Once assigned, every save goes into a branch; approval groups must all approve a gated transition; reaching the last step activates the revision. Publishing stays separate. Add a filterable tag facet to a listing Tags are flat, shared across types and already filterable on every listing route: append /tags/<slug> to the listing path. Build the facet from the tags in use, mark the active one from the route's tag variable, and combine with + or comma.