Customizing Error Pages

Post

Posted
Rating:
#3785 (In Topic #744)
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
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.
Online now: No Back to the top

Post

Posted
Rating:
#3790
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
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.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3803
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’

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.
Online now: No Back to the top

Post

Posted
Rating:
#3804
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
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.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3806
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
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
Online now: No Back to the top

Post

Posted
Rating:
#3808
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
I suspect your Apache is too old to support variables then.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3810
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Yeah, I found it - I'm running 2.2. Oh well.

Thanks though Chris :thumbs:
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Forum statistics:
  • 2,053 topics, 7,195 posts, 10,839 members
  • Our newest member is PurplewaveIndia
Birthdays:
Back to Top