octobercms/october · error · ApplicationException

cms::lang.template.not_found

Error message

cms::lang.template.not_found

What it means

loadTemplate() in the editor extension CRUD trait calls <Type>::load($theme, $path) for the resolved template class; a falsy result (template not found in the theme datasource) throws 'Template not found.'

Source

Thrown at modules/cms/classes/editorextension/HasExtensionCrud.php:230

        $content = str_replace('__SELF__', $componentAlias, $content);

        return [
            'content' => $content
        ];
    }

    /**
     * loadTemplate returns an existing template of a given type
     * @param string $documentType
     * @param string $path
     * @return mixed
     */
    private function loadTemplate($documentType, $path)
    {
        $class = $this->resolveTypeClassName($documentType);

        if (!($template = call_user_func([$class, 'load'], $this->getTheme(), $path))) {
            throw new ApplicationException(trans('cms::lang.template.not_found'));
        }

        // Handle snippets
        if ($documentType === EditorExtension::DOCUMENT_TYPE_PARTIAL) {
            Snippet::processTemplateSettings($template);
        }

        /**
         * @event cms.template.processSettingsAfterLoad
         * Fires immediately after a CMS template (page|partial|layout|content|asset) has been loaded and provides an opportunity to interact with it.
         *
         * Example usage:
         *
         *     Event::listen('cms.template.processSettingsAfterLoad', function ((\Cms\Classes\EditorExtension) $extension, (mixed) $templateObject) {
         *         // Make some modifications to the $template object
         *     });
         *
         * @deprecated remove second arg 'editor', context no longer used

View on GitHub (pinned to b608633a7e)

Solutions

  1. Refresh the editor / reopen the document list so metadata is rebuilt
  2. Verify the file exists under themes/<editTheme>/<typeDir>/<path> (pages/, partials/, layouts/, content/, assets/, meta/)
  3. Check Theme::getEditTheme() returns the theme you expect
  4. If the file was removed intentionally, close the stale editor tab
Defensive patterns

Strategy: validation

Validate before calling

$theme = \Cms\Classes\Theme::getEditTheme();
if (!\Cms\Classes\Page::load($theme, $path)) {
    // template gone: refresh the list, close the tab, or show 'not found' with context
}

Prevention

When it happens

Trigger: The editor requests a template path that does not exist in the current edit theme — file deleted outside the editor, path taken from stale metadata, wrong edit theme active, or a path casing mismatch.

Common situations: Templates deleted on disk while the editor list is open; switching edit themes while an editor tab retains the old path; deploys where case-sensitivity differs; database-layer template records deleted under the editor.

Related errors


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/7db65047b6e9c73e. Report an issue: GitHub.