Welcome Guest, Not a member yet? Register   Sign In
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

(This post was last modified: 05-28-2018, 02:04 AM by neuron.)

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




Theme © iAndrew 2016 - Forum software by © MyBB