Friday 6 July 2007

Mediawiki Hooks

Programming a mediaWiki extension relies on using the Hooking system to edit and update the mediawiki objects to the state you desire. So the first problem is finding the right hooks. I have found 3 ways to do this...

Using the documentation
There is a document called hooks.txt in the docs directory. Read it.

Finding undocumented hooks
At the bottom of hooks.txt are 2 lines that explain this. Simply put, you call a php script.
php ./maintenance/findhooks.php
This finds all the hooks that are missing from the hooks.txt documentation.

Find out the variables being passed to your hook called function
From you mediawiki base directory call: [grep -i -n -r "wfRunHooks" *] this will show all calls to wfRunHooks and allows you to see the line number in the calling file as well as what is being passed to your hook call. This is very useful as the documentation is sparse on the passed variables.

No comments:

Post a Comment