2

I have a Structure named "pages" which is set to use the template named "_entry".

When trying to visit one of the pages I’m just getting a blank screen.

The Craft log shows an error in the template loader because it can’t find a template.

Craft\TemplateLoaderException: Unable to find the template "about/index". in /path/to/site/craft/app/etc/templating/twigextensions/TemplateLoader.php:123

The structure is set to use the template named _entry which is present and all as it should be.

I have tried renaming the template to no avail.

Other parts of the site are working fine. It only seems to be this Structure that has a problem.

The problem is occurring on an Azure VM running Ubuntu 16.04 LTS with PHP 7.0, running MySQL 5.7 with Strict mode disabled and managed with ServerPilot. I'm pretty sure it's been working OK since I deployed to Azure a couple of days ago but I can't explicitly remember testing these pages since my involvement has largely been on a different part of the site (which is working OK).

This is working fine locally, and has been working fine on a test server set up at Digital Ocean (I've decommissioned that but I'm in the process of setting it up again to test this).

Update: I can confirm the same code works perfectly on the Digital Ocean/ServerPilot combo so it appears to be something Azure or possibly MySQL 5.7 related (the Azure deployment is using MySQL 5.7 with Strict mode disabled)

Update: I'd incorrectly read the error message. The _entry template appears to be found. But this is then trying to load another template (in this case about/index) which is where things fail. There is no about/index template it should fall through to a generic template.

{% if craft.request.getSegment(2) %}
    {% set internal = craft.request.getSegment(1) ~ '/' ~ craft.request.getSegment(2) %}
    {% set index = craft.request.getSegment(1) ~ '/index' %}
{% else %}
    {% set internal = entry.uri ~ '/index' %}
    {% set index = entry.uri ~ '/index' %}
{% endif %}

{% include [internal, index, '_generic'] ignore missing %}
1

Got to the bottom of it!

The _entry template relies on the fact there's a template error.

On the production site I'd added,

'suppressTemplateErrors' => true

to the config, which stopped the behaviour that was being relied upon to serve the generic template

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.