CWA 2 is a prerelease (2.0.0-alpha), heading for a beta. It runs production sites; configuration can still change between releases, always with upgrade notes. View versions and support
Extending the CWA

Page Data Tabs and Lists

Adding an extension's own tab to the page data dialog, and lists of page data to its admin area, for the page data types that have a property the extension works with.

An extension can add to the admin's page data screens as well as its own pages. A shop that adds product variants to page data can give the page data dialog a Formats and prices tab, and give its own area a Products list of the page data that has variants.

Both are matched to page data types by a property, never by the type's name: a tab or list applies to every page data type whose API documentation lists the property named in forTypesWithProperty. The site decides which types have it, so the extension works with any of them.

// cwa-shop/module.ts, in register({ … })
pageDataTabs: [
  { key: 'formats', label: 'Formats and prices', file: resolve('./admin/formats.vue'), forTypesWithProperty: 'variants' },],
pageDataLists: [
  {
    path: 'products',    label: 'Products',    forTypesWithProperty: 'variants',    columns: [{ label: 'From', file: resolve('./admin/from-price.vue') }],
  },
],

A Tab in the Page Data Dialog

OptionRequiredWhat it does
keyYesThe tab's key, and its hash: #formats opens the dialog on this tab
labelYesThe tab's name
fileYesAn absolute path to the tab's Vue file
forTypesWithPropertyYesThe API property a page data type must have for the tab to show
roleNoThe role a user needs to see the tab. Default ROLE_CMS_ADMIN, the role that opens the page data dialog

The tab sits after Details and before Routes, in the order the extensions declare their tabs. It isn't shown while a new record is being added, because there's nothing saved for it to work on yet.

The tab's component gets two props: iri, the page data record's IRI, and data, the record as loaded. It saves through the API itself, for example with useCwaAdminItem or its own requests. Its saves are separate from the dialog's: they don't count towards Save, and leaving the tab unsaved doesn't mark the dialog as unsaved.

<!-- cwa-shop/admin/formats.vue -->
<script setup lang="ts">
const props = defineProps<{ iri: string, data: Record<string, any> }>()
</script>
A tab's key can't be details, routes or info, the built-in tabs' keys, and two extensions can't use the same key. Either one fails the build.

Hiding a Tab for One Type

A site that doesn't want the tab on one of its types turns it off in that type's pageData config:

// app/nuxt.config.ts
cwa: {
  pageData: {
    BookPageData: { hideExtensionTabs: ['formats'] },  },
},

See Nuxt Config › Full cwa: Reference.

A List of Page Data in the Extension's Area

OptionRequiredWhat it does
pathYesThe list's path in the extension's area: products is /_cwa/shop/products
labelYesThe list's tab in the area
forTypesWithPropertyYesThe API property a page data type must have to be listed
roleNoThe role a user needs to open the list. Default ROLE_ADMIN, as for admin pages
columnsNoExtra columns after Title, each { label, file }

A list is a tab of the extension's area, after its admin pages (see Admin Pages › The Extension's Area). It shows one page data type at a time:

  • /_cwa/shop/products lists the types that have the property. When only one type has it, it goes straight to that type's list.
  • /_cwa/shop/products/<type> lists that type's records, with search and sorting by date or title. <type> is the class's short name with a lower-case first letter, such as bookPageData.
  • A row opens the record's page data dialog over the list, at /_cwa/shop/products/<type>/<iri>, with the extension's page data tabs in it.

The routes are named _cwa-shop-products, _cwa-shop-products-type and _cwa-shop-products-type-iri.

A column's component gets the row's record as its data prop:

<!-- cwa-shop/admin/from-price.vue -->
<template>
  <span>{{ from }}</span>
</template>

<script setup lang="ts">
import { computed } from 'vue'

const props = defineProps<{ data: Record<string, any> }>()
const from = computed(() => Math.min(...(props.data.variants ?? []).map((variant: { price: number }) => variant.price)))
</script>
Image placeholder: the Shop area's Products tab listing books, with Title and From columns, and a book's page data dialog open on its Formats and prices tab.

When the Build Fails

Besides the checks in Registering an Extension › When the Build Fails:

ProblemMessage
A tab with a built-in tab's key@acme/cwa-shop's page-data tab "details" has the key of the built-in Details tab
Two extensions with one tab key@acme/cwa-shop and @acme/store both have the page-data tab "formats"
A tab without forTypesWithProperty@acme/cwa-shop's page-data tab "formats" needs forTypesWithProperty, the API property a page data type must have to show it
A tab without a label@acme/cwa-shop's page-data tab "formats" needs a label
A list without forTypesWithProperty@acme/cwa-shop's page-data list /_cwa/shop/products needs forTypesWithProperty, the API property a page data type must have to be listed
A list with an admin page's path@acme/cwa-shop's page-data list /_cwa/shop/products has the path of its own admin page /_cwa/shop/products

A tab or list role must start with ROLE_ and can't be ROLE_USER, as for admin pages.

Next: Sign-In and Sign-Out Events.