Pre-computed data

Run the expensive query once, not on every request

A Data View is a Twig definition that builds a data structure, stored as JSON and rebuilt when the collections it reads from change. Templates fetch the finished result.

Pro

Data Views require the Pro edition or higher, and access is controlled separately through Access Groups using the dataviews permission — both gates have to pass. Users without that permission cannot see or manage views at all.

A view is written as a Twig template, called its definition, with the full CMS context available: cms.collection.objects(), cms.collection.search() and everything else you use in a page template. The definition's job is to set a data variable holding whatever structure you want stored; that variable is serialized to JSON when the view is built. Instead of counting, filtering and joining on every page load, the work happens once and templates read the finished result with a single cms.view.get('view-id') call.

Rebuilds look after themselves. The Dependencies field lists the collections a view reads from, and any create, update or delete in one of them queues the view for rebuild through the job queue — so the queue does need to be processing for automatic rebuilds to happen. A view can also read another view's output; list those under View Dependencies and Total CMS both orders the rebuilds correctly and gives the downstream view the upstream one's collection dependencies, so you do not have to repeat them.

The obvious use is a dashboard number, but the more valuable one is a join. Team members carry a department id, departments live in their own collection, and every page that shows a member would otherwise re-resolve that map. A view walks both collections once and stores members with their department names already attached; templates loop over a plain array.

The admin has a Test Run button that executes a definition without saving, showing either the JSON output or the Twig error, plus a manual Rebuild View. If a build fails, the previous data is kept so your templates keep rendering, the error is logged, and a red indicator appears next to the view's name.

Views are also reachable by AI agents through the MCP server — but that exposure is a separate, narrower gate, controlled by the view's own mcp.access field rather than by access groups. Leave it at the default admin unless the output is genuinely safe for every caller at the tier you choose.

What you get

Written in Twig you already know

The definition is a template with full CMS context. Set a data variable; Total CMS stores it as JSON and hands it back on demand.

Rebuilds when its data changes

List the collections a view depends on and any create, update or delete queues a rebuild through the job queue. No manual invalidation.

Views can build on views

List other views under View Dependencies and Total CMS orders the rebuilds and inherits their collection dependencies. Cycles are detected and logged.

Test before you save

The Test Run button executes a definition without storing anything, showing the JSON output or the exact Twig error.

A failed build never breaks a page

If a rebuild fails, the previous data is kept and templates keep working. The error is logged and flagged with a red indicator in the admin.

In practice

One snippet

{# The definition: build a data variable #}
{% set posts = cms.collection.objects('blog') %}
{% set products = cms.collection.objects('products') %}

{% set data = {
    "blog": {
        "total": posts|length,
        "published": posts|filter(p => not p.draft)|length
    },
    "products": {
        "total": products|length,
        "featured": products|filter(p => p.featured)|length
    }
} %}

{# In any template: read the pre-computed result #}
{% set stats = cms.view.get('dashboard-stats') %}
{{ stats.blog.published }} published posts

The definition runs when the view is built; the template only reads stored JSON, however many collections went into it.

FAQ

Common questions

When does a view rebuild?

When any object in a collection listed under Dependencies is created, updated or deleted, the view is queued for rebuild through the job queue — so the queue has to be running. You can also rebuild manually from the admin at any time.

What if I don't set dependencies?

The view still works, but it will only rebuild when you trigger it manually. Set the dependencies to match the collections your definition actually reads, or list an upstream view under View Dependencies and inherit its collections.

Who can see a Data View?

Data Views need Pro or higher, and access is granted per user through Access Groups with the dataviews permission. MCP exposure is separate and narrower: a view surfaced to agents is governed by its own mcp.access field, which defaults to admin.

Can a view read another view?

Yes, with cms.view.get inside the definition. List the upstream view under View Dependencies so the build order is right and its collection dependencies are inherited. Two views listing each other is a cycle — detected at rebuild time, logged, and best avoided.