error_404()

public function error_404(): void

Description

Displays the 404 error page. This method is automatically invoked by Trongate when a requested URL cannot be matched to any existing route. It loads the error_404 template view, which provides a user-friendly message indicating that the requested page could not be found. The method can be customised by editing the template view file or by changing the ERROR_404 constant in the configuration file to point to a different module and method.

Parameters

Parameter Type Description Default Required
This method takes no parameters.

Return Value

Type Description
void This method does not return a value. It outputs the complete HTML error page directly.

Example #1

The code sample below shows the default ERROR_404 constant definition found in config/config.php. This constant determines which module and method Trongate calls when a 404 error occurs.

Example #2

This example demonstrates how to manually trigger a 404 error from within your own controller method when certain conditions are not met.

Example #3

This example shows how to redirect the ERROR_404 constant to a custom error handling method in a different module.

Example #4

This example demonstrates creating a custom 404 handler with additional logging functionality before displaying the error page.