Plugin Handling Class - Extends the CI_Hooks Class |
[eluser]Xeoncross[/eluser]
That is mostly right. It is the SAME EXACT way the current hooks works - only it allows more hook points (other than the standard 8 and also adds a "filter" function for hooks that should return data (and not just run). Here is the code: Hooks.php Code: $hook['filter_comment'][] = array( controller: Code: //Create data (array, string, object, whatever) filter.php Code: function filter($data) And you now have a filter that process comments! You can also pass by reference (if you don't want return statements in your code) and you can register multiple functions/objects to run on data. I.E. Code: //Check akismet for spam There is no need to load the hooks class in your controller because CI loads it already! The perfect example of this whole hooks/plugins thing is parsing a comment/text body. Some people want markup others use Cleaned HTML - still others only use BBCODE! With a simple plugin/hook call like above you can swap out the text filter to any type you want! |
Welcome Guest, Not a member yet? Register Sign In |