[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