How To Make A Custom Page Not Found Page for Opencart

Making a custom “Page Not Found” page for Opencart is actually fairly simple once you figure it out. The only real tricky part to this is that you have to modify three files to make it work instead of just two files like you might use in osCommerce.

It’s fairly straightforward that you would modify your language page which is here:


What we did was under the line:

// Text

$_['text_error'] = ‘The work truck hardware and equipment page you requested cannot be found.’;

we added a line like this one:

// Text Page

$_['text_page'] = ‘The page you requested cannot be found. WorkTruck Outfitters was completely rebuilt on October 14th, 2012. If you are seeing this page, you may have been brought here by a search engine or one of your bookmarks. We apologize for the inconvenience! That exact url does not exist.<br><b>There are quite a few options to find the work truck product you were looking for.</b><br>First off, you can call us. 877-360-7278.<br> You can try using our search box in the top left area of our web page.<br>You may find our sitemap very helpful. <li><a href=”index.php?route=information/sitemap”><b>Work Truck Outfitters Sitemap</b></a></li><br> Or, you may want to try one of these popular links:<br><br><li><a href=”backup-cameras-trucks”><b>Backup Cameras For Trucks</b></a></li><li><a href=”air-compressors-trucks”><b>Air Compressors For Trucks</b></a></li><li><a href=”crane-pallet-forks”><b>Crane Pallet Forks</b></a></li><li><a href=”jump-start-equipment/goodall-startalls”><b>Goodall StartAlls</b></a></li><li><a href=”hardware-work-trucks”><b>Hardware For Work Trucks</b></a></li><li><a href=”outrigger-pads”><b>Outrigger Pads For Crane Trucks</b></a></li><li><a href=”power-inverters-for-trucks”><b>Power Inverters For Trucks</b></a></li><li><a href=”utility-body-bed-covers”><b>Utlity Body Bed Covers</b></a></li><li><a href=”warn-winches”><b>Warn Winches and Hoists</b></a></li><li><a href=”wheel-chocks”><b>Wheel Chocks</b></a></li>’;

That adds the text and links in the “Page Not Found” page. But to call that line into action, you have to call it in the template page found here:


So, under this line:

<div class=”content”><?php echo $text_error; ?></div>

We added this line:

<div class=”content”><?php echo $text_page; ?></div>

In osCommerce, that’s all it would have taken. But in Opencart, we have to do one more edit to make this work. If not, you’re going to get an “Undefined variable” error message that looks like this:

Notice: Undefined variable: text_page in / on line 10

So, we now need to modify one more line:

In /catalog/controller/error/not_found.php

Find the line that reads:

$this->data['text_error'] = $this->language->get(’text_error’);

and add under that this:

$this->data['text_page'] = $this->language->get(’text_page’);

That’s it. Now when a visitor get’s your “Page Not Found” page on your Opencart site, they’ll be able to get the full message you want to get accross so they can find the product they were looking for.

// Text
$_['text_error']    = ‘The work truck hardware and equipment page you requested cannot be found.’;