Use Language on Error Handling - show_error() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Use Language on Error Handling - show_error() (/showthread.php?tid=77989) |
Use Language on Error Handling - show_error() - nicolas33770 - 11-16-2020 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 RE: Use Language on Error Handling - show_error() - nicolas33770 - 11-21-2020 Any help !? ? RE: Use Language on Error Handling - show_error() - superior - 11-21-2020 You can use the language helper function to define the different languages on errors. PHP Code: echo lang('language_key'); for more information see: https://codeigniter.com/userguide3/helpers/language_helper.html RE: Use Language on Error Handling - show_error() - nicolas33770 - 11-23-2020 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() Quote:Type: Error If I try have got a new error Quote:public function csrf_show_error() Quote:A PHP Error was encountered RE: Use Language on Error Handling - show_error() - superior - 11-23-2020 Helper doesn't seem to be loaded, you need to add this in your autoloader RE: Use Language on Error Handling - show_error() - nicolas33770 - 11-23-2020 We can't load helper on /var/www/gml-app/gml_system/core/Security.php, it's not working. :-( RE: Use Language on Error Handling - show_error() - superior - 11-23-2020 (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'); RE: Use Language on Error Handling - show_error() - nicolas33770 - 11-23-2020 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 ? RE: Use Language on Error Handling - show_error() - superior - 11-23-2020 (11-23-2020, 08:21 AM)nicolas33770 Wrote: Thanks for your help ! I just have 2 more question please : Did you read the documentation about this? - https://codeigniter.com/userguide3/general/core_classes.html RE: Use Language on Error Handling - show_error() - nicolas33770 - 11-23-2020 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. |