Welcome Guest, Not a member yet? Register   Sign In
set 404 custom error
#4

(07-04-2020, 08:41 PM)ajayamagar Wrote: This line of code worked for me.
$routes->set404Override('App\Controllers\Errors:Confusedhow404');

I did a little bit different ...

Route:
PHP Code:
<?php namespace Config;

// Create a new instance of our RouteCollection class.
$routes Services::routes();

// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH 'Config/Routes.php'))
{
 require 
SYSTEMPATH 'Config/Routes.php';
}

/**
 * --------------------------------------------------------------------
 * Router Setup
 * --------------------------------------------------------------------
 */
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override(function()
{
    $header = array (
    'icon' => 'favicon',
    'css' => 'nodata',
    'title' => 'Page not found - wdeda',
    'action' => '/search/allmedia/',
    'placeholder' => 'Search'
    );
    
    
echo view('templates/headerr'$header);
    echo view('content/error_404');
    echo view('templates/footerfb');
    });
$routes->setAutoRoute(true);

/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/''Home::index');

/**
 * --------------------------------------------------------------------
 * Additional Routing
 * --------------------------------------------------------------------
 *
 * There will often be times that you need additional routing and you
 * need to it be able to override any defaults in this file. Environment
 * based routes is one such time. require() additional route files here
 * to make that happen.
 *
 * You will have access to the $routes object within that file without
 * needing to reload it.
 */
if (file_exists(APPPATH 'Config/' ENVIRONMENT '/Routes.php'))
{
 require 
APPPATH 'Config/' ENVIRONMENT '/Routes.php';


The view:
PHP Code:
<!-- 20200524 -->

 <
div class="content-container">
 <
div class="message">
 <
img alt="Oops" src="/public/img/common/wd-20200416-oops.png" />
 <
span class="msgerror">ERRO 404página não encontrada.</span>
 <
h2>
 - 
What the f***!<br />
 - 
Houstonwe have a problem here.
 </
h2>
 <
h4>Às vezesisso pode acontecerNos desculpe pelo inconveniente.</h4>
 </
div>
 <
div class="links">
 <
p><a href="http://localhost">Retornar à página inicial</a></p>
 <
p><a href="mailto://[email protected]">Entrar em contato conosco para reportar um problema.</a></p>
 </
div>
 </
div


Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
set 404 custom error - by eleumas - 04-23-2020, 03:15 AM
RE: set 404 custom error - by ajayamagar - 07-04-2020, 08:41 PM
RE: set 404 custom error - by wdeda - 07-05-2020, 02:41 PM
RE: set 404 custom error - by InsiteFX - 07-05-2020, 03:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB