Welcome Guest, Not a member yet? Register   Sign In
Plugin Handling Class - Extends the CI_Hooks Class
#7

[eluser]simshaun[/eluser]
Excuse my blatant idiocy, but let me see if I understand this correctly.

My goal is this:

I have a page controller, which loads a block of text from the database and passes it as a variable into the view.

With your hooks code, In my controller I can do
Code:
$data = $this->somemodel->getSampleContent();

$this->hooks->filter('data_filter', $data);

And then someone can make a plugin that contains
Code:
function custom_data_filter($data)
{
    $data = htmlentities($data);
    $data = stripslashes($data);
}

....

As I was making that.. I kinda got lost where I put '....'.
Care to help?

Ideally, this is what I want to do:
In my controller:
Code:
class Hooks extends Controller {

    function Hooks()
    {
        parent::Controller();    

        //Instantiate the hooks class
        $this->hooks =& load_class('Hooks');
    }

    function index()
    {
        $data['body_content'] = 'This sentence & that sentence.';
        
        $this->hooks->apply_filters('body_content_filters', &$data['body_content']); // can you pass by reference like that?

        $this->load->view('page_view', $data);
    }

}

And in a plugin:
Code:
function my_content_filter($input)
{
    $output    = htmlentities($input);
    return $output;
}

$CI =& get_instance();                ## Need to eliminate this line, but I don't know where else to put it so developers don't need to have it.
$CI->hooks =& load_class('Hooks');    ## Need to eliminate this line, but I don't know where else to put it so developers don't need to have it.

$CI->hooks->register_filter('my_content_filter', 'body_content_filters');

Hope you understand that.
Now, is it doable? lol


Messages In This Thread
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 08-05-2008, 06:23 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 08-05-2008, 07:00 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 08-05-2008, 07:15 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 08-05-2008, 07:24 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 08-05-2008, 07:34 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 08-05-2008, 07:42 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-30-2008, 04:02 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-30-2008, 05:32 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-30-2008, 05:46 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-30-2008, 05:50 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-30-2008, 06:20 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-30-2008, 06:29 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-30-2008, 06:34 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-30-2008, 06:41 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-30-2008, 06:47 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-30-2008, 06:51 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-31-2008, 04:22 AM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-31-2008, 11:42 AM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-31-2008, 11:43 AM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-31-2008, 11:49 AM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-31-2008, 11:51 AM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-31-2008, 11:55 AM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-31-2008, 12:00 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 12-31-2008, 12:08 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 07-15-2009, 12:55 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 07-15-2009, 01:04 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 07-15-2009, 01:55 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 07-15-2009, 02:00 PM
Plugin Handling Class - Extends the CI_Hooks Class - by El Forum - 07-16-2009, 08:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB