Moin,
On Saturday 08 April 2006 06:49, Tim Starling wrote:
Tels wrote:
Here is a snippet from DynamicPageList2:
// The callback function for converting the input text to HTML output
function DynamicPageList2( $input ) {
...
global $wgTitle;
global $wgOut;
$ts = mktime();
$now = gmdate("YmdHis", $ts + 60);
$ns = $wgTitle->getNamespace();
$ti = wfStrencode($wgTitle->getDBkey());
... [snip]
$wgOut->addMeta("http:Pragma", "no-cache");
...
Please don't use $wgTitle in parser hook functions, it will break the
job queue, and anything else that wants to parse more than one article.
runJobs.php is set up to die with a backtrace if anyone attempts it.
Instead, take a parser object as the third parameter, and use the
$parser->mTitle member variable. Like this:
function DynamicPageList2( $input, $params, &$parser ) {
...
$ns = $parser->mTitle->getNamespace();
...
As Brion points out, using $wgOut won't work either, because data sent
to $wgOut won't be saved in the parser cache. That's why all data
generated in parser hooks needs to find its way into the ParserOutput
object. Put an array of head items there, have the parser hook add one,
maybe via an accessor in Parser. Then have OutputPage copy those items
to itself in OutputPage::addParserOutputNoText(). Then it will all work
with the parser cache.
Could you give some short example of how that would be written? Also does
this need 1.6 or would it work with 1.5.x too?
I intend to write a FAQ about all this later, and toy around with it. That
is certainly underdocumented and thus done wrong by some extensions. :)
Thanx for the time and explanations,
Tels
--
Signed on Sat Apr 8 12:07:00 2006 with key 0x93B84C15.
Visit my photo gallery at
http://bloodgate.com/photos/
PGP key on
http://bloodgate.com/tels.asc or per email.
"A bus station is where a bus stops. A train station is where a train
stops. On my desk I have a work station." -- Unknown