Hey guys.

I really need help here. I've looked everywhere, but I can't find anything I understand. And I never use code I don't understand: I'm pretty new to PHP.


I'm building a blog/cms system and I need a way to easily allow the use of plugins.


The plugins should have access to the $this-> object of the current class. It should also work a little like hooks like this:

<?php
// do stuff
$plugins->execute("before_render");

// do stuff
//render
?>

The plugins class should load all the plugins (in the beginning of the app) and then execute the ones that are labeled to be executed in the hook point "before_render."

Now, imagine I have something like this, in a class:

<?php
// do stuff
$this->content = "test";

$plugins->execute("before_render");

echo $this->content;

?>

And in the plugin, it says something like:

<?php
$this->content = "asdfsadf";

?>
So that when the page loads, $this->Content has been changed by the plugin!

I've already made a hooks system, and it works quite well. However it has no ability to access the parent class. I saw something somewhere which uses "implements Plugins" or something like, but I don't understand that.

Basically what I'm asking for is a really short and clean example of how I would do all this.

I found an example of what I mean: http://www.w3style.co.uk/?p=9. That code looks really complex and unnecessary, can someone help explain it better or help me write this cleaner?

Thanks so much!