Hi,
I need to use language on Error Handling - show_error() and show_404() but I don't find a way to do that.
For exemple the file "system/core/Security.php" the function csrf_show_error() have the text error directly here.
Is it a simple way to use my language file for this ?
I tried to load view on "application/views/errors/html/error_general.php" to use a specific header and footer view on this error but I can't. Do you know what I need to do that ?
Thanks for your help

Thanks for this reply but it's not working. I got this error when I try to use this.
Form Security.php
Quote:public function csrf_show_error()
{
show_error(lang('message_error_403'), 403);
}
Quote:Type: Error
Message: Call to undefined function lang()
Filename: /var/www/gml-app/gml_system/core/Security.php
Line Number: 298
Backtrace:
File: /var/www/gml-app/index.php
Line: 310
Function: require_once
If I try have got a new error
Quote:public function csrf_show_error()
{
$this->lang->load('gml_general', 'french');
show_error(lang('message_error_403'), 403);
}
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Security::$lang
Filename: core/Security.php
Line Number: 298
Backtrace:
File: /var/www/gml-app/index.php
Line: 310
Function: require_once
An uncaught Exception was encountered
Type: Error
Message: Call to a member function load() on null
Filename: /var/www/gml-app/gml_system/core/Security.php
Line Number: 298
Backtrace:
File: /var/www/gml-app/index.php
Line: 310
Function: require_once
Helper doesn't seem to be loaded, you need to add this in your autoloader
We can't load helper on /var/www/gml-app/gml_system/core/Security.php, it's not working. :-(
(11-23-2020, 07:59 AM)nicolas33770 Wrote: [ -> ]We can't load helper on /var/www/gml-app/gml_system/core/Security.php, it's not working. :-(
Yes you can, just override this class with a MY_ class.
Would be something like this, did not test this so feel free to improve
PHP Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class MY_Security extends CI_Security
{
public function __get($instance) {
return get_instance()->$instance;
}
public function csrf_show_error() {
$this->load->helper('language');
$this->lang->load('gml_general', 'french');
show_error( lang( 'message_error_403' ), 403 );
}
}
Thanks for your help ! I just have 2 more question please :
- Where I put the MY_Security.php file ?
- Is it possible to improve your code to load my views/header_view.php ?
(11-23-2020, 08:21 AM)nicolas33770 Wrote: [ -> ]Thanks for your help ! I just have 2 more question please :
- Where I put the MY_Security.php file ?
- Is it possible to improve your code to load my views/header_view.php ?
Did you read the documentation about this?
-
https://codeigniter.com/userguide3/gener...asses.html
I must admit that it seems to me quite complex especially if I have to create a specific and class page for each of the error pages (error_404, error_db, error_exception, error_general, ...)
I never indeed use these functions extension. I would just like to personalize all these pages simply.
I would just like to be able to load a view ( $this->load->view('header'); ) in "gml_application/views/errors/html/error_404.php" but it also doesn't work.
I guess it's because of CI_Controller not being loaded, I may not know how to load it either. It is all very technical.