Hi,
I would want to create a simple parser extension which creates a new page (similar to the inputbox of Eric Moeller), but the idea of my parser extension would be to take the current category(s) of the article where the inputbox is placed on and automatically use the same categories on the new page you provide to the inputbox. This way if you create a new article from a page that's listed in the categories "Visual Basic" and "Coding Tips" would also automatically propose these categories on the newly created page, which would greatly simplify the process a user has to go through to create a page.
Now the problem, I've thrown some code together (see below) but I'm stuck at the very start of my idea: the problem is that $wgOut->mCategoryLinks is an empty array (I would normally pass the value of the categories via a hidden input in the form).
Anyone knows if there is any way to determine the categories of the current article at this point? Any other possible solution? All ideas are very welcomed.
Cheers, Peter.
my code: <?php
$wgExtensionFunctions[] = "wfAParserExtension";
function wfAParserExtension() { global $wgParser;
# register the parser extensions with the WikiText parser $wgParser->setHook( "newarticle", "render_newarticle" ); }
// render_newarticle // parses the <newarticle></newarticle> tag function render_newarticle ( $input, $argv ) { global $wgOut;
print_r ($wgOut->mCategoryLinks); // mCategoryLinks empty array here :(
$action = htmlspecialchars( $wgScript ); $createform=<<<ENDFORM <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td> <form name="newarticle" action="$action" method="get" class="newarticle"> <input type='hidden' name="action" value="edit"> <input type='hidden' name="preload" value=""> <input class="newarticleInput" name="title" type="text" value="" /> <input type='submit' name="create" class="newarticleButton" value="Add Article"/> </form> </td> </tr> </table> ENDFORM; return $createform; }
?>