views:

265

answers:

2

I created a few mediawiki custom tags, using the guide found here

http://www.mediawiki.org/wiki/Manual:Tag_extensions

I will post my code below, but the problem is after it hits the first custom tag in the page, it calls it, and prints the response, but does not get anything that comes after it in the wikitext. It seems it just stops parsing the page.

Any Ideas?

if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
        $wgHooks['ParserFirstCallInit'][] = 'tagregister';
} else { // Otherwise do things the old fashioned way
        $wgExtensionFunctions[] = 'tagregister';
}


function tagregister(){
    global $wgParser;
    $wgParser->setHook('tag1','tag1func');
    $wgParser->setHook('tag2','tag2func');
    return true;
}

function tag1func($input,$params)
{
    return "It called me";
}

function tag2func($input,$params)
{
    return "It called me -- 2";
}

Update: @George Mauer -- I have seen that as well, but this does not stop the page from rendering, just the Mediawiki engine from parsing the rest of the wikitext. Its as if hitting the custom function is signalling mediawiki that processing is done. I am in the process of diving into the rabbit hole but was hoping someone else has seen this behaviour.

+1  A: 

Never used Mediawiki but that sort of problem in my experience is indicative of a php error that occurred but was suppressed either with the @ operator or because php error output to screen is turned off.

I hate to resort to this debugging method but when absolutely and utterly frustrated in php I will just start putting echo statements every few lines (always with a marker so I remember to remove them later), to figure out exactly where the error is coming from. Eventually you'll get to the bottom of the rabbit hole and figure out exactly what the problematic line of code is.

George Mauer
A: 

Silly me.

Had to close the tags.

Instead of<tag1> I had to change it to <tag1 /> or <tag1></tag1>

Now all works!

Adam Lerman