Welcome Guest, Not a member yet? Register   Sign In
Hooking display_override - $this->output->get_output not working
#1

[eluser]Stuart Marsh[/eluser]
I'm trying to use the display_override hook to edit output before it gets to the user.
I created the following hook:
Code:
class display_hook {
    
    function NewOutput()
    {
        $content = $this->output->get_output();        
    }
}
In the manual it syas that $this->output->get_output() should work but it doesn't.
I get this error:
Code:
Message: Undefined property: Display_Hook::$output
Call to a member function _display() on a non-object
So I then tried this code:
Code:
class display_hook extends Controller {
    
    function NewOutput()
    {
        $content = $this->output->get_output();        
    }
}
This works but creates another problem. When I try to load a model in a controller is gives me this error:
Code:
Message: Undefined property: Display_Hook::$DB_Content
Fatal error: Call to a member function _assign_libraries() on a non-object

So I have two questions:
1 - What is the correct format for a hook class so I can use $this->output->get_output()?
2 - Why can't I load a model when I extend the controller for my hook?

Any help would be appreciated.
#2

[eluser]Unknown[/eluser]
Are you ensuring that you make a reference to the CI superobject before you make a call to get_output on it? i.e.:

Code:
$this->CI =& get_instance();
$this->CI->output->get_output();
#3

[eluser]Stuart Marsh[/eluser]
oops should have updated this.
I posted this as a bug here: http://codeigniter.com/bug_tracker/bug/4512/
The manual used to say that $this->output->get_output() would work, but has since been changed to reflect the correct code.




Theme © iAndrew 2016 - Forum software by © MyBB