How to make custom module show error404
Posted: Mon Apr 12, 2010 1:41 am
Hello,
I am creating a module which introduces a new Content Type for the pages.
In some cases I need the page with My Content Type to show error 404 (not found).
What is the best way to do it?
I would like to show the content of CMSMS built-in page with alias "error404", and at the same type to send http header status = 404 (not found).
I tried this:
however in this case it sends http header = 302 and once redirection was done - status = 200 Ok
Maybe I should try something like this?
Question: how to get and display the content of the page with alias "error404"?
Or maybe there is another solution to my problem?
I am creating a module which introduces a new Content Type for the pages.
In some cases I need the page with My Content Type to show error 404 (not found).
What is the best way to do it?
I would like to show the content of CMSMS built-in page with alias "error404", and at the same type to send http header status = 404 (not found).
I tried this:
Code: Select all
if( [condition not met] ){
$contentops =& $gCms->GetContentOperations();
$this->RedirectContent($contentops->GetPageIDFromAlias('error404'));
}
Maybe I should try something like this?
Code: Select all
if( [condition not met] ){
header("HTTP/1.0 404 Not Found");
[include the contents of error404 page]
die();
}
Or maybe there is another solution to my problem?