Page 1 of 1

Custom 404 Page

Posted: Sun Mar 04, 2012 9:17 am
by rockyalifept
I want to have a custom error page, I wonder if it's possible?
I want to buy one from this site, for example this one: http://themeforest.net/item/simplistic-404/1538456
But I don't know if it's possible to insert ir or how to do it, can anybody help me?
Thanks in advance ;)

(I have the 1.5.1.3.1 Opencart version.)

Custom 404 Page

Posted: Sun Mar 04, 2012 12:23 pm
by SamNabz
Hi rockyalifept,

Download the custom 404 page you want, edit it to suit your website (e.g. colours links etc.). Once you've done that, copy all the coding (including styling) and paste it into the not_found.tpl file located in catalog/view/theme/yourthemename/template/error/

Paste the code within <div class="content"> </div> and be sure to de-activate or delete this <?php echo $text_error; ?> - to de-active, replace this:

Code: Select all

<?php echo $text_error; ?>
with this

Code: Select all

<!--<?php echo $text_error; ?>-->
Let me know how you go...

Custom 404 Page

Posted: Sun Mar 04, 2012 6:38 pm
by rockyalifept
I'm very thankful for your help!
As soon as I buy the custom page I will install it and tell you how it went!
Thanks

Re: Custom 404 Page

Posted: Tue Mar 20, 2012 5:18 am
by MrTech
Your solution doesn't really work because you will get this page when you visit an empty cart page or goto checkout and there are no items in your cart.

I've been searching the forums for an answer and the closest I've found is this:
http://forum.opencart.com/viewtopic.php?f=20&t=20507

The code posted is for an older version of opencart and doesn't support seo url's as per the author. Just wondering if anyone has found a working solution to what should be an easy peasy fix?

Re: Custom 404 Page

Posted: Tue Mar 20, 2012 5:32 am
by smifis
This isn't really all that hard to do,

The not_found.tpl file is only for 404 errors in version 1.4.x and 1.5.x and you can safely edit this file, it will not affect the cart or any other errors pages as these are made using their respective controller.

Re: Custom 404 Page

Posted: Tue Mar 20, 2012 6:33 am
by MrTech
@smifis - Can you confirm this is working for you currently on v1.5.2.1? The reason I ask is because I've gone ahead and tried again based on your post and get the same results. Here's an example of a quick edit to the file, please correct me where I'm wrong...

This is the file I modified:

Code: Select all

catalog\view\theme\default\template\error\not_found.tpl
This is the code that I modified:

Code: Select all

<div class="content"><?php echo $text_error; ?></div>
I added 'HELLO WORLD' after the error message like this:

Code: Select all

<div class="content"><?php echo $text_error; ?>HELLO WORLD!</div>
Now, as I posted initially, I will see the error message along with the words "HELLO WORLD!" on the 404 page, checkout page and shopping cart page. If I remove the entire error string, then I only see the two words, again displayed across all pages.

Can someone else test the above and let me know your results? Thanks!

Re: Custom 404 Page

Posted: Tue Mar 20, 2012 6:44 am
by smifis
Just looked into it a little bit deeper,

here's what to do, create a 2nd copy of '/catalog/controller/view/default/template/error/not_found.tpl' called 'error_404.tpl'

In the file 'catalog/controller/error/not_found.php', replace

Code: Select all

		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
		} else {
			$this->template = 'default/template/error/not_found.tpl';
		}
with

Code: Select all

		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/error_404.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/error/error_404.tpl';
		} else {
			$this->template = 'default/template/error/error_404.tpl';
		}
error_404.tpl is your new 404 error file, you can replace its entire contents if you wish.

Re: Custom 404 Page

Posted: Tue Mar 20, 2012 11:22 am
by MrTech
That did the trick! Thanks for your time...

Re: Custom 404 Page

Posted: Wed Jul 18, 2012 9:03 pm
by techfi
Hi there!
I have done everything said here, but I dont have an error_404.tpl page, only an error_404.php page, can I edit the PHP file as I please or have I missed a step?

Also, my URL is livinthing.com , if I add /test123 , should an error page appear ? because when this happens to me I get

Not Found

The requested URL /test123 was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Any ideas on how I can fix this and get a propper error 404 page which I can edit?

Re: Custom 404 Page

Posted: Sat Feb 09, 2013 7:13 pm
by Cleo
I know this is an old thread but since I don't know if the problem have been corrected in the new version I prefer to ask.

@smifis


You said:
here's what to do, create a 2nd copy of '/catalog/controller/view/default/template/error/not_found.tpl' called 'error_404.php'
If the file to be copied has the extension .tpl shouldn't the second file be .tpl as well or is it really .php?

Just want to be sure :drunk:

tks

Cleo

Re: Custom 404 Page

Posted: Sat Feb 09, 2013 9:55 pm
by smifis
Sorry that should be .tpl and not .php

I will edit the post to remove any confusion.

Re: Custom 404 Page

Posted: Sun Feb 10, 2013 11:13 am
by Cleo
Fine, thank you for the reply and clarification!

Cleo

Re: Custom 404 Page

Posted: Sun Feb 17, 2013 3:08 am
by pringle12345
Has anyone here ever worked with Smifis?

Re: Custom 404 Page

Posted: Sun Feb 17, 2013 3:20 am
by Cleo
Well it didn't work anyway :(



@ pringle

Never did!

Cleo

Re: Custom 404 Page

Posted: Mon Sep 02, 2013 11:32 am
by slewman
@smifis a big thank you to you for this solution. Works perfectly for 1.5.6
You saved what's left of my hair O0

Re: Custom 404 Page

Posted: Thu Jun 26, 2014 2:13 am
by hnimzpig
Step 1:
open file /catalog/controller/error/not_found.php
add "//" before this line
$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
like this:
//$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
Step 2:
open file /catalog/controller/view/your_current_theme/template/error/not_found.tpl to modify what you want to show.

That the way I do with my site http://www.d-city.net. Hope this way could help you!