• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using helpers on error pages

#1
Hello there,

sorry if this is a noob question but here goes...

I am trying to use the functions link_tag and base_url (from html_helper and url_helper) on the default 404 error page for links to css files and images but I can't seem to get it to work since there is no controller to include the helpers.

Is there an easy solution to this?
Reply

#2
404 page is handled by system/core/Expeptions.php

to customize it extend it in application/core/MY_Exceptions.php

PHP Code:
class MY_Exceptions extends CI_Exceptions{

public function 
show_404($page ''$log_error TRUE){

$CI =& get_instance();

        $CI->load->helper('url');
//your custom code

    }

Reply

#3
(05-28-2018, 02:04 AM)neuron Wrote: 404 page is handled by system/core/Expeptions.php

to customize it extend it in application/core/MY_Exceptions.php

PHP Code:
class MY_Exceptions extends CI_Exceptions{

public function 
show_404($page ''$log_error TRUE){

$CI =& get_instance();

        $CI->load->helper('url');
//your custom code

    }


Thank you for the answer, sadly this didn't work for me. The get_instance function returns null when I call it in this context.

I have a workaround now in which I just copied the code that the url_helper runs to get the base url. Not really pretty but it works for now.
Reply

#4
get_instance is working in my project, I overrided it as I explained in my reply
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.