On 27/11/05, Amruta Lonkar gtg808u@mail.gatech.edu wrote:
# This method will be called before an article is saved $wgHooks['ArticleSaveComplete'][] = 'myFunction';
# This method will be called before an article is displayed or previewed. $wgHooks['ParserAfterStrip'][] = 'myOtherFunction';
But where in my extension do i put this code? Will it come outside of the 2 functions in the extension file or should it be inside the renderExample function?
The idea according to docs/hooks.txt is that they be added in a "setup function" for the extension - i.e. the same one referenced in $wgExtensionFunctions[] which calls $wgParser->setHook() to setup the <ref>...</ref> bit.
As far as I can see, though, it ought to be just as possible to do this in "global" scope, outside of any class or function but inside the same file as the extension so it can be activated and deactivated with a single include() line.
I certainly *wouldn't* recommend putting it in the function that actually gets called to parse a <ref> tag, as that will lead to odd things like it hasn't been called [yet], or has been called more than once (in which case your other functions would be called more than once) and so forth.
-- Rowan Collins BSc [IMSoP]