Welcome Guest, Not a member yet? Register   Sign In
Bespoke 404 Error Page
#1

[eluser]JamesTaylor[/eluser]
I'm wanting to implement a bespoke 404 page to a website i'm building - I can see that its possible to edit the error_404.php file in application/errors folders but i'm wondering if or how its possible to control it via a controller, in much the same way as each page is handled?

My aim to utilize my template file which has the main site components included such as the header, main navaigation and footer etc. - i then just want to load in in a simple 404 error message which will take on the styling of the rest of the site etc.

Is my aim easily achievable or do i have to dupilcate all the code from my template into the error_404.php file?

Thanks

James
#2

[eluser]jrtashjian[/eluser]
Use
Code:
show_404();
wherever you need to show a 404 page.
#3

[eluser]JamesTaylor[/eluser]
Thanks jrtashjian, but doesn't this just point to the error_404.php file which i would then have to style accordingly? I am trying to avoid having multiple versions of my template file so that i don't have to update multiple version if any alterations are made etc.

I may be missing something regarding its implementation? Can you explain further how you would use it?
#4

[eluser]jrtashjian[/eluser]
Yes, this only points to the error_404.php file. The only code you'd be "duplicating" is the HTML. If you're linking CSS and Javascript files in the top of your template, you shouldn't have any issues unless you're changing html structure.
#5

[eluser]JamesTaylor[/eluser]
Thanks jrtashjian,

the dupliaction of any code is exactley what i'm trying to avoid... however little the duplication is.

The only thing i ideally want in my error_404.php is the 404 error message, everything else should be brought from the master template file which is used for all the other pages.
#6

[eluser]InsiteFX[/eluser]
Read this by Phil Sturgeon!

CodeIgniter Base Classes: Keeping it DRY

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB