• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
GoodForNothing Four Oh! Four

GoodForNothing Four Oh! Four 1.1.2 Beta 1

No permission to download
Custom 404 page for your XenForo site, now with a logging mechanism...

Mr. Goodie2Shoes

Well-known member
#1
Mr. Goodie2Shoes submitted a new resource:

Four-oh!-Four by xenCODE (version 1.0.0) - Changes XenForo's default 404 page

Introduction
This add-on will just simply overwrite the XenForo's default Error System (by overwrite, I mean the program, NOT any files) with a custom one. I've added a 'mockup' which you can edit/change/update to your liking.

NOTE: This add-on only handles 404 request, nothing else ;)

Important
Do not rename the file '4oh4.php' if you don't have any knowledge on PHP, else you will trigger indefinite redirection loops (which is really nasty, trust me ;) )

Installation
  1. Firstly,...
Read more about this resource...
 

ArnyVee

Well-known member
#2
Ah, very cool.

I was going to start working on something like this as I wanted a custom page for my 404 error pages. :D

I will be testing this out next week. Thanks for offering this add-on for the community (y)
 

Mr. Goodie2Shoes

Well-known member
#6
Here is a mario 404 page! :D

1. Upload mario404.jpg to /styles/xenCode/.

2. In 4oh4.php search for:

Code:
background: url("styles/xenCODE/404.png") no-repeat scroll 0 0 transparent;
Change /styles/xenCode/404.png to /styles/xenCode/mario404.png

Then your done! :)
You've made a mistake or missed a point: ;)
change
Code:
background: url("styles/xenCODE/404.png") no-repeat scroll 0 0 transparent;
to
Code:
background: url("styles/xenCODE/mario404.jpg") no-repeat scroll 0 0 transparent;
and the directory is 'xenCODE' NOT 'xenCode'...
 

Matthew2D

Well-known member
#7
You've made a mistake or missed a point: ;)
change
Code:
background: url("styles/xenCODE/404.png") no-repeat scroll 0 0 transparent;
to
Code:
background: url("styles/xenCODE/mario404.jpg") no-repeat scroll 0 0 transparent;
and the directory is 'xenCODE' NOT 'xenCode'...
Thanks. I fixed it. ;)
 
#8
Unfortunately, your add-on does not make sense SEO-wise.
Search engines will consider missing pages okay as your add-on returns 301 and then 200 HTTP codes. This will clutter search index of your website with lots of different links leading to 404 page that are considered valid by the search engine. This may lead to your website lowering in search results.
 

Mr. Goodie2Shoes

Well-known member
#9
Mr. Goodie2Shoes updated GoodForNothing Four Oh! Four with a new update entry:

Fixed Bugs, Removed Redirection, Re-written the code.

Updates
  • Fixed issue regarding SEO: added 404 header
  • Removed Redirection: now the error page is shown on the same page
To Fix:
Upload and overwrite everything from the upload folder. If you have edited the 4oh4.php file used in the previous version, open and copy everything and edit the file /library/GFNCoders/Templates/404.tpl and overwrite everything :)
Read the rest of this update entry...
 
#10
Unfortunately, your add-on does not make sense SEO-wise.
Search engines will consider missing pages okay as your add-on returns 301 and then 200 HTTP codes. This will clutter search index of your website with lots of different links leading to 404 page that are considered valid by the search engine. This may lead to your website lowering in search results.
Thank you for the feedback... I actually didn't thought that way :D
anyways, the issue has been fixed. :)
 
#11
Thank you for the feedback... I actually didn't thought that way :D
anyways, the issue has been fixed. :)
Rendering the file is not the best way. You can store the template in the database and simply specify it in the response, i.e.:
Code:
return $this->responseView('GFNCoders_FourOhFour_ViewPublic_404', 'GFNCoders_404');
You will also need to modify your ViewRenderer:
Code:
public function renderRaw()
{
    $this->_response->setHttpResponseCode(404);
    $this->_response->setHeader('Content-Type', 'text/html; charset=UTF-8', true);
    return $this->createTemplateObject($this->_templateName, $this->_params);
}
Also using globals is considered a bad practice. And use HTML5 doctype please as XenForo itself uses it.

P.S.: You can make use of XenForo's base url variable to use relative paths in the template:
Code:
<xen:if is="{$requestPaths.fullBasePath}">
    <base href="{$requestPaths.fullBasePath}" />
</xen:if>
and you don't have to duplicate default behavior in the controller. You can simply call parent method:
Code:
public function actionErrorNotFound()
{
    if (XenForo_Application::debugMode())
    {
        return parent::actionErrorNotFound();
    }
    else
    {
        $this->_routeMatch->setResponseType('raw');
        return $this->responseView('GFNCoders_FourOhFour_ViewPublic_404', 'GFNCoders_404');
    }
}
if you correctly use XenForo's class proxy and extend your class from "XFCP_GFNCoders_FourOhFour_ControllerPublic_Error"

I've tried all this and it worked.
 
#13
Rendering the file is not the best way. You can store the template in the database and simply specify it in the response, i.e.:
Code:
return $this->responseView('GFNCoders_FourOhFour_ViewPublic_404', 'GFNCoders_404');
You will also need to modify your ViewRenderer:
Code:
public function renderRaw()
{
    $this->_response->setHttpResponseCode(404);
    $this->_response->setHeader('Content-Type', 'text/html; charset=UTF-8', true);
    return $this->createTemplateObject($this->_templateName, $this->_params);
}
Also using globals is considered a bad practice. And use HTML5 doctype please as XenForo itself uses it.

P.S.: You can make use of XenForo's base url variable to use relative paths in the template:
Code:
<xen:if is="{$requestPaths.fullBasePath}">
    <base href="{$requestPaths.fullBasePath}" />
</xen:if>
and you don't have to duplicate default behavior in the controller. You can simply call parent method:
Code:
public function actionErrorNotFound()
{
    if (XenForo_Application::debugMode())
    {
        return parent::actionErrorNotFound();
    }
    else
    {
        $this->_routeMatch->setResponseType('raw');
        return $this->responseView('GFNCoders_FourOhFour_ViewPublic_404', 'GFNCoders_404');
    }
}
if you correctly use XenForo's class proxy and extend your class from "XFCP_GFNCoders_FourOhFour_ControllerPublic_Error"

I've tried all this and it worked.
okay added everything... and btw, you dont have to go so detailed... just
how about adding the template to database?
would have sufficed :p
 

ddmmh

Well-known member
#14
Nice add-on, definatley want to use this.

I host my forums in a sub directory /community

Is there a way I can make this universal across the entire site including directories not in /community? I just read your update, and according to that its bad for SEO to re-direct to a 404 page which is EXACTLY what I do in my .htaccess and I need to find a better solution, thanks
 
#15
Nice add-on, definatley want to use this.

I host my forums in a sub directory /community

Is there a way I can make this universal across the entire site including directories not in /community? I just read your update, and according to that its bad for SEO to re-direct to a 404 page which is EXACTLY what I do in my .htaccess and I need to find a better solution, thanks
Sorry, this add-on ONLY handles XenForo 404 Error.
and redirecting to 404 page using .htaccess wont harm if you're using
Code:
ErrorDocument 404 ~file~
because it automatically sets the '404 File Not Found' header ;)
 

Mr. Goodie2Shoes

Well-known member
#18