Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

404 error page #58

Open
Brain8torm opened this issue Sep 13, 2017 · 0 comments
Open

404 error page #58

Brain8torm opened this issue Sep 13, 2017 · 0 comments

Comments

@Brain8torm
Copy link

Hi!
Could you tell me how to make a 404 error page through your router. For example, instead of the plain text "404" on an empty page, another page was loaded - at /404/ with the same or its template?

For example, I create this page with path /404/:

Macaw::get('/404/', '\Controllers@error404Page');

In Controllers.php I add a function:

public function error404Page()
{
	header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
	$this->layout = Template::getInstance('error404.tpl');
	$this->layout->set("title", "404 Error - Not found");
	$this->layout->set("content", '404 Error: Oops! Nothing found');

	echo $this->layout->output();
}

In this case, we open the page /404/, but it gives the code 200, since the router is specified.

Thanks!

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant