Skip to Content
Developer GuideContent Types in Code

Content Types in Code

You create a content type in Visor, with no code. See Content Types, or ask a connected AI tool. It then appears in the menu with its workflow, permissions and scope set up for you, so editors can use it straight away.

Code is needed only to show it on the website.

What a content type is called

Visor generates the technical name from the display name and the site.

KindTechnical nameIn code
With workflowxtr_cms_data_news_a1b2c3xtr_cms_data_news
Simple dataxtr_cms_simple_links_a1b2c3xtr_cms_simple_links
Shared with all sitesxtr_cms_data_newsxtr_cms_data_news

a1b2c3 is the site’s key. Use the name without the key. lib/daas.ts adds it for you, so your code works on any site.

Show items in a widget

There’s no general widget for listing any content type, so you create a site widget for each one. The create-widget and daas-api-patterns skills know these patterns.

Read the items

On the server, use readItems:

import { readItems } from "@/lib/daas"; const rows = await readItems("xtr_cms_data_news_translations", { filter: { status: { _eq: "Published" }, language_code: { _eq: languageId }, xtr_cms_data_news_id: { _nnull: true }, }, fields: ["title", "slug", "summary", "image"], sort: ["-date_created"], limit: 6, });

Read them in the client variant

Browser code can’t call GoDaaS, so the client variant calls POST /api/data-sources instead.

Use buildDataHref, buildDataHierarchy or attachDataResolvedHrefs, instead of writing paths by hand.

Rules

KindWhat to know
Translated typeRead the _translations collection. Filter on status, which is the exact string Published, and on language_code, which is the language’s ID. Require the parent link to be non-null.
Child listThe child’s link column, such as trip_id, holds the parent’s default-language translation ID.
Simple dataIt has no title, slug or status. Use your own fields.

Pages read published content only, including under npm run dev, so a new item appears once it’s published.

An item’s own page

Each item of a workflow type gets its own page under /articles/, whatever the type is called. A translated item in another language is under /<code>/articles/.

/articles/<parents>/<slug> /id/articles/<parents>/<slug>

An item appears only once it and all its parents have a published translation. Simple data has no pages of its own, so show it with a widget.

To choose how these pages look, set the type’s layout in Content Type Layouts, or use visor_type_layout_set. The VdsArticleLayout layout includes a rich text widget that shows the item’s own text.

Your own route

You can add a route such as app/events/[...slug]/, which is one of your site’s places. Be aware of two things:

  • The build’s page-switching script handles only the template’s own routes, so your route’s page.tsx runs as it is in every mode.
  • In the live build it needs its own generateStaticParams.

Test yours in both modes. See Rendering modes.

Hard to undo

Once pages, widgets or the site’s code use a type, renaming or removing it breaks them. Agree the types with your team before you build on them.

Last updated on