Create the Fall-Back Page Template

Before we forget and move on to something else, let’s create a fall-back template. The reason we had a white page when we came to the site was because we didn’t have a full.php file in the site. But what happens if someone adds a package at some point that adds its own page templates, “Foo” and “Bar”, with the handles “foo” and “bar,” respectively. Any pages that these templates get applied to will not render at all, because there won’t be foo.php and bar.php files in the theme.

To fix this problem, let’s create a default.php file in the theme directory. Any time a page is rendered and its page template file can’t be found, default.php will be rendered in its place. We don’t even have to repeat ourselves in this file; instead, let’s just set this file up to include the content of our most popular template, full.php.

touch default.php

Edit default.php in your editor, and add these contents:

<?php
defined('C5_EXECUTE') or die('Access Denied.');
$view->inc('full.php');

$view is an object corresponding to the Concrete\Core\Page\View\PageView object in the current scope; it contains a method named inc() that includes files within the current theme. Just set your default page template up this way, and it will include the contents of the full-width template; you won’t have to keep both of them in sync.