How to create a 404 page - Page Not Found

This tutorial is over a year old and may not apply to your version of Concrete CMS.
Apr 29, 2016

Creating an Error 404 Page

If your Theme does not include a file named page_not_found.php, you can create your own.

Create a page_not_found.php

Upload the file to application/themes/CustomThemeFolder (or where your theme is)

Then add the following

<?php
defined('C5_EXECUTE') or die("Access Denied.");
$this->inc('elements/header.php'); ?>

<main>
    <div class="container">
        <div class="row">
            <div class="col-sm-9 col-sm-offset-3">
                <div class="jumbo">
                    <h1><?php echo t('404 Error')?></h1>
                    <p><?php echo t('Page not found.')?></p>
                </div>
            </div>
        </div>
    </div>
</main>

<?php  $this->inc('elements/footer.php'); ?>

If you want to make your 404 page editable with a search, use the following instead.


<?php defined('C5_EXECUTE') or die("Access Denied."); $this->inc('inc/header.php'); ?> <div id="main-content" class="main-container"> <div class="main-content-inner clearfix"> <main role="main"> <div class="container"> <div class="row"> <div class="col-sm-8 col-sm-offset-2"> <main role="main"> <article> <?php $a = new Area('Main'); $a->enableGridContainer(); $a->display($c); ?> </article> </main> <div class="jumbo"> <h1><?php echo t('404 Error')?></h1> <p><?php echo t('Page not found, so please search.')?></p> <?php $bt = BlockType::getByHandle('search'); $bt->controller->title = t('Search'); $bt->controller->buttonText = t('Search'); $bt->render(); ?> </div> </div> </div> </div> </main> </div> </div> <?php $this->inc('inc/footer.php'); ?>

Find out how to optimize you 404 error page.

Recent Tutorials
Create custom Site Health tasks
Apr 19, 2024
By myq.

This tutorial will guide you through the creation of a new Site Health task

Reusing the same Express entity in multiple associations
Apr 11, 2024
By myq.

How to create and manage multiple associations in Express

Express Form Styling
Apr 11, 2024
By myq.

Different ways to style Express forms

Setting addon/theme version compatibility in the marketplace
Jan 9, 2024

For developers worn out with setting the latest addon or theme version manually across too many core versions, here is a JavaScript bookmarklet to do it for you.

How to get the locale of a page
Jan 8, 2024
By wtfdesign.

Now, why don't we just have a getLocale() method on Page objects beats me, but here's how you work around it

Using a Redis Server
Jun 16, 2023
By mlocati.

How to configure Concrete to use one or more Redis servers to persist the cache.

Improvements?

Let us know by posting here.