craftcms / craftcms/cms

errorTemplatePrefix not being applied

Open
#5,059 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

I added errorTemplatePrefix to the general.php but it is not overwriting the default behavior.

Steps to reproduce

general.php:
'errorTemplatePrefix' => "_tm/errors/",

404.twig location:
/templates/_tm/errors/404.twig

If I access an inexisting url:
HTTP 404 – Not Found – yii\web\NotFoundHttpException
Template not found: dsfsfsdf
1. in /Users/pauloniciolipaes/Documents/WORK/Ticketmaster/DEV/tracking_manager_craft/vendor/craftcms/cms/src/controllers/TemplatesController.phpat line 93

If I move the 404.twig the template root folder (/templates/404.twig) then it works even though errorTemplatePrefix is set to point to a different location

Additional info

PHP version 7.3.9
OS version Darwin 18.6.0
Database driver & version MySQL 5.7.27
Image driver & version GD 7.3.9
Craft edition & version Craft Pro 3.3.7
Yii version 2.0.21
Twig version 2.11.3
Guzzle version 6.3.3
Imagine version 1.2.3-dev

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the errorTemplatePrefix setting in general.php and the template lookup reported at TemplatesController.php line 93. Reproduce using templates/_tm/errors/404.twig and an invalid URL, then trace why the configured prefix is ignored. Done means the prefixed 404.twig is used without moving it to templates/404.twig.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.