# Blocks

## Cards in a grid, with a picture, a heading, text and a button.

## Basics: what module-blocks is

**module-blocks** is the generic card module in CCMS for showing several information cards in one section.

Each card can contain a heading, text, an image and an optional CTA button. The same foundation is also used by several specialised variants (for example steps, products, videos and audio), but this page documents the base variant.

The module is designed for high reuse: the same JSON structure can run as `flow`, `tabs` or `slider` without changing the core content.

## Option 1: core keys and structure

The top level lives in `blocks`, with keys such as `module_type`, `id`, `aria_label`, `section_title`, `section_description`, `columns` and `layout`.

The content is written in `items[]`, where each item can have:

- `display` , `title` , `text_html`
- `image.*` (cover/media)
- `video.*` and `audio.*` (optional)
- `button.*` for the CTA
- `appearance` and `display_below_desktop_class`

The background of the whole section is controlled by `background.have_background`, `background.background_src` and `background.background_overlay`.

## Option 2: layout (flow, tabs, slider)

`layout` is normalised to three modes:

- **flow** : a regular grid showing several cards at once.
- **tabs** : one active card at a time with tab navigation.
- **slider** : an active card with arrows/pagination and optional autoplay.

Tabs use `tabs_settings` (position, mobile position, start index and appearance). The slider uses `slider_settings` (index_start, loop, arrows, pagination, arrows_position, auto and auto_interval).

If invalid values are passed in, the build falls back to safe defaults, for example `layout: flow`.

## Option 3: card level, media and CTA

Each item becomes a card with its own appearance and responsive class. Images automatically get `srcset`/ `sizes` from the manifest when `image.src` is used.

Video and audio are rendered in the media zone with an overlay/play button. When `columns=1`, `blocks.is_one_column` is set, which affects video source selection in the template.

In the current implementation, the card's button uses `button.href` directly. Unlike hero/big_button, there is no separate auto-href resolver for `blocks.button`.

## Option 4: compiler and runtime details

The build normalises `items[]` into `block1..blockN` and computes `blocks.auto_display` from the visible cards. The template currently renders up to `block12`, so cards beyond twelve are not shown unless the template is extended.

`slider_settings.auto_interval_ms` is clamped to 1000–120000 ms, and `index_start` is clamped to the number of visible cards.

The client script builds the tabs/slider controls from data attributes in the HTML. For audio in blocks, the template renders `preload="none"`, regardless of any preload keys in the content data.

## Option 5: schema, SEO and AI optimisation

For generic blocks, `ItemList` is a good base: one list object for the section and one `ListItem` per visible card.

Map `title` to `name` and a short summary of `text_html` to `description`. Add `url` when the card has a CTA link, and `image` when the card image is semantically important.

Avoid duplicating global schema nodes in the module. Instead, keep the module's schema focused on the cards' content and actions.
