Customizing Error Pages

Post

Posted
Rating:
#3738 (In Topic #746)
Joe
Not on a server level, but within Composr. So when you go to a page that doesn't exist, I want to be able to modify the template that shows the "an error has occurred" page.

I would've assumed it was WARN_SCREEN.tpl, as this template has something to do with missing resources and displays the site-map, but I edited this and the error page was not altered.

Post

Posted
Rating:
#3739
I believe a missing page is MISSING_SCREEN.tpl. A missing resource (e.g. category, entry, …) is WARN_SCREEN.tpl (as it's just classified as a kind of warning). And a 404 error taken in from .htaccess (e.g. a broken link to a static file) is the page named 404.

Post

Posted
Rating:
#3750
Joe

Chris Graham said

I believe a missing page is MISSING_SCREEN.tpl. A missing resource (e.g. category, entry, …) is WARN_SCREEN.tpl (as it's just classified as a kind of warning). And a 404 error taken in from .htaccess (e.g. a broken link to a static file) is the page named 404.

Thanks Chris, that's the one.

Just one more question:

When someone visits something that doesn't exist, I've got my .htaccess to redirect to Composr's 404 page. On this page I've created my own little 'stack trace' sort of thing that collects info about the user, puts it in a fancy HTML table, and allows the user to copy and paste this info and send it off in a ticket (used for bug reporting). I was hoping to display some referrer information there so the user can include this in the ticket, which in turn would help me diagnose the issue.

I tried using {$PAGE} and {$QUERY_STRING} but this just outputs the URL to the 404 page, so I think I'd need to get some referrer info in there since the .htaccess is referring the user to Composr's 404 page.

Is there something already in place of Composr that collects referrer information so I can relay it onto the actual 404 error page? Or is there something else you could recommend?

I thought about just copying the source HTML from a Composr page to get my layout, and copy this into a server-level custom error page where I'd be able to use tags to collect the referrer (cPanel's error page generator uses <!--#echo var="HTTP_REFERER" --> in a SHTML file which I tried using within the 404 Comcode page, but didn't work and just gave me an error within Composr), however I'd have to change the source code every time I make an edit to my theme.

This one is more server level, maybe you can't help me here but I figured I'd ask.

Post

Posted
Rating:
#3751
Try something like this in .htaccess:

Code

ErrorDocument 404 /index.php?page=404&orig_url=%{REQUEST_URI}

Then this Tempcode: {$_GET,orig_url}

Apparently works in Apache 2.4+.

On my server I couldn't get it to work any other way, no automatic environment variables told me the original URL.

Post

Posted
Rating:
#3753
Joe
It almost works!

The .htaccess treats %{REQUEST_URI} as text and just outputs it as the same, so my URL looks like this:

Code

index.php?page=404&orig_url=%{REQUEST_URI}

I tried to find my Apache version in phpinfo, didn't have any luck.

I'll also keep trying to find a work around. Now that I know how to get the parameters from .htaccess into Composr, I just need to find a variable that works with my .htaccess

Post

Posted
Rating:
#3755
I suspect your Apache is too old to support variables then.

Post

Posted
Rating:
#3757
Joe
Yeah, I found it - I'm running 2.2. Oh well.

Thanks though Chris :thumbs:
1 guest and 0 members have recently viewed this.