Skip to content

Twig Admin Reference

The admin adapter provides methods for the admin interface including dashboard statistics, job queue management, URL rewrite rule generation, and system diagnostics.

Get summary statistics for the admin dashboard.

{% set stats = cms.admin.dashboardStats() %}
<p>{{ stats.collections }} collections</p>
<p>{{ stats.schemas }} schemas</p>
<p>{{ stats.templates }} templates</p>
<p>{{ stats.totalObjects }} total objects</p>
<p>{{ stats.jobs }} pending jobs</p>

Returns: array with keys collections, schemas, templates, totalObjects, jobs

Get the 10 most recently updated accessible collections.

{% for col in cms.admin.dashboardRecentCollections() %}
<a href="{{ col.url }}">{{ col.name }} ({{ col.objectCount }} objects)</a>
{% endfor %}

Get collections with zero objects that may need attention.

{% set empty = cms.admin.dashboardEmptyCollections() %}
{% if empty|length > 0 %}
<h3>Empty Collections</h3>
{% for col in empty %}
<p>{{ col.name }} has no objects yet</p>
{% endfor %}
{% endif %}

Get system status information including PHP version, CMS version, cache backends, memory limits, and license info.

{% set status = cms.admin.dashboardSystemStatus() %}
<p>PHP {{ status.phpVersion }}</p>
<p>CMS {{ status.cmsVersion }}</p>

Get the 10 most recently created or updated objects across all collections.

{% for obj in cms.admin.dashboardRecentObjects() %}
<p>{{ obj.id }} in {{ obj.collection }}{{ obj.updated }}</p>
{% endfor %}

Get the CLI command string for processing the job queue. Useful for displaying setup instructions in the admin.

<code>{{ cms.admin.processJobQueueCommand() }}</code>

Get an HTML table showing pending jobs in the queue.

{{ cms.admin.jobQueuePendingInfo()|raw }}

Get an HTML table showing failed jobs.

{{ cms.admin.jobQueueFailedInfo()|raw }}

Get development mode status as an array.

{% set devMode = cms.admin.devModeStatus() %}
{% if devMode.active %}
<div class="dev-banner">Development Mode Active</div>
{% endif %}

Check if development mode is currently active.

{% if cms.admin.isDevModeActive() %}
<div class="debug-panel">...</div>
{% endif %}

Group all templates by their folder path for admin sidebar navigation.

{% for folder, templates in cms.admin.templatesByFolder() %}
<h4>{{ folder }}</h4>
<ul>
{% for tpl in templates %}
<li>{{ tpl.name }}</li>
{% endfor %}
</ul>
{% endfor %}

Returns: array<string, array> — folder paths as keys, arrays of template info as values

Generate Apache mod_rewrite rules for pretty URLs.

{{ cms.admin.apacheRule(cms.currentUrl, 'Blog Posts') }}
ParameterTypeDescription
urlstringThe URL pattern to rewrite
collectionstringLabel for the comment (default: 'Collection')

Generate Nginx rewrite rules for pretty URLs.

{{ cms.admin.nginxRule(cms.currentUrl, 'Products') }}
ParameterTypeDescription
urlstringThe URL pattern to rewrite
collectionstringLabel for the comment (default: 'Collection')

Build an HTMX-powered quick action button. The route is relative to the site base, so it can target any route — include the /api prefix for API routes, or point at a public route like an automation webhook. (A leading slash is optional; /api/cache/clear and api/cache/clear are equivalent.)

{{ cms.admin.quickActionButton('Clear Cache', '/api/cache/clear', {
method: 'post',
confirm: 'Are you sure?',
reload: true,
class: 'btn-danger'
})|raw }}
{# Fire an automation webhook (sameOrigin auth) from a page #}
{{ cms.admin.quickActionButton('Run Report', '/automations/build-report', {
confirm: 'Queue the report build?'
})|raw }}
OptionTypeDefaultDescription
methodstring'post'HTTP method
confirmstring''Confirmation message before executing
reloadboolfalseReload page after action completes
redirectstring''Redirect URL after action completes
classstring''Additional CSS classes

The response is not swapped into the page (hx-swap: none) — use reload or redirect when the action’s effect should become visible.

Prior to 3.5.0-rc.13 the /api prefix was added automatically, which made it impossible to target public routes. Update any custom templates by adding the prefix explicitly ('/cache/clear''/api/cache/clear').

Get collections that are inaccessible due to the current edition restrictions.

{% set locked = cms.admin.inaccessibleCollections() %}
{% for col in locked %}
<p>{{ col.name }} requires a higher edition</p>
{% endfor %}

Get schema IDs that are inaccessible due to the current edition restrictions.

{% set locked = cms.admin.inaccessibleSchemas() %}
{% for schemaId in locked %}
<p>{{ schemaId }} schema is not available</p>
{% endfor %}

The admin adapter also exposes diagnostic sub-objects:

{# Server information #}
{{ cms.admin.checker.serverInfo() }}
{{ cms.admin.checker.checkRequiredSoftware() }}
{{ cms.admin.checker.checkOptionalSoftware() }}
{{ cms.admin.checker.getVersion() }}
{# Cache status #}
{{ cms.admin.cacheReporter.getStatus() }}
{# Error logs #}
{{ cms.admin.logAnalyzer.getRecentErrors(10) }}