Hi, I've made a little parser extension for my needs.
I want this extension add automatically the page where it's called to a category, say Category:Foobar.
In my function, I wrote : return $wgOut->parse('blabla[[Category:Foobar]]');
but my page isn't added to category Foobar. "blabla" is working very well.
What is wrong with my code ? Thanks in advance,
-- Sylvain http://tousauxbalkans.jexiste.fr http://iubito.free.fr
On 20/05/06, iubito iubito@gmail.com wrote:
Hi, I've made a little parser extension for my needs.
I want this extension add automatically the page where it's called to a category, say Category:Foobar.
In my function, I wrote : return $wgOut->parse('blabla[[Category:Foobar]]');
but my page isn't added to category Foobar. "blabla" is working very well.
What is wrong with my code ?
You're using the wrong parser. The parser that $wgOut uses discards the parser output, which is where things like link table updates come from.
Something like:
$parser->parse( "...", $parser->mTitle, $parser->mOptions, false, false);
where $parser is the parser object passed to the hook; should work.
Rob Church
I changed to $wgParser
function renderMedia($input) { global $wgParser; return $wgParser->parse('...', $wgParser->mTitle, $wgParser->mOptions, false, false); } Note that $parse in Parser.php is marked as @access private, should I use it ? or should it become public ? my server runs php4 so that's not a problem now for me.
Ok the page is added to category, but parse() returns an Object, not a string. In my older version, return $wgOut->parse(...) returned a string of the HTML output.
What's wrong ?
2006/5/20, Rob Church robchur@gmail.com:
On 20/05/06, iubito iubito@gmail.com wrote:
Hi, I've made a little parser extension for my needs.
I want this extension add automatically the page where it's called to a category, say Category:Foobar.
In my function, I wrote : return $wgOut->parse('blabla[[Category:Foobar]]');
but my page isn't added to category Foobar. "blabla" is working very
well.
What is wrong with my code ?
You're using the wrong parser. The parser that $wgOut uses discards the parser output, which is where things like link table updates come from.
Something like:
$parser->parse( "...", $parser->mTitle, $parser->mOptions, false, false);
where $parser is the parser object passed to the hook; should work.
Rob Church _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
On 20/05/06, iubito iubito@gmail.com wrote:
I changed to $wgParser
function renderMedia($input) { global $wgParser; return $wgParser->parse('...', $wgParser->mTitle, $wgParser->mOptions, false, false); } Note that $parse in Parser.php is marked as @access private, should I use it ? or should it become public ? my server runs php4 so that's not a problem now for me.
Ok the page is added to category, but parse() returns an Object, not a string. In my older version, return $wgOut->parse(...) returned a string of the HTML output.
What's wrong ?
1. Your parser hook will be given a parser object to use. Use that as $parser with this function definition:
function renderMedia( $input, $args, &$parser )
2. The parse() function returns a ParserOutput object. So do something like
$output = <parse statement> return $output->getText();
Rob Church
OK thanks ! Everything works very well now !
2006/5/20, Rob Church <robchur@gmail.com >:
On 20/05/06, iubito iubito@gmail.com wrote:
I changed to $wgParser
function renderMedia($input) { global $wgParser; return $wgParser->parse('...', $wgParser->mTitle, $wgParser->mOptions, false, false); } Note that $parse in Parser.php is marked as @access private, should I
use it
? or should it become public ? my server runs php4 so that's not a
problem
now for me.
Ok the page is added to category, but parse() returns an Object, not a string. In my older version, return $wgOut->parse(...) returned a string of the
HTML
output.
What's wrong ?
- Your parser hook will be given a parser object to use. Use that as
$parser with this function definition:
function renderMedia( $input, $args, &$parser )
- The parse() function returns a ParserOutput object. So do something
like
$output = <parse statement> return $output->getText();
Rob Church _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org