Topic on Project:Support desk

Access extension function inside skin

5
Swami-elevati (talkcontribs)

MediaWiki : 1.23.2 PHP : 5.4.30 MySQL : 5.6.19

I have created a custom extension which fetch data from database, process it and provide result. I want to call this extension function inside my skin. Or Is there any hook on which I can call my extension function and access its result in skin?

Thanks in advance.

Florianschmidtwelzow (talkcontribs)

Maybe you can describe more detailed, what you want to to? Where you want to add what? Has it really to be into the skin or into pages (think about, that page content is cached, so your data, too, if you use a parser hook, otherwise your extension do the db queries and calculating work every page impression). If you don't want to do that, you can use this hook SkinTemplateOutputPageBeforeExec, which allows you to add some data to the template, e.g.:

public static function onSkinTemplateOutputPageBeforeExec( &$skin, &$tpl ) {
    $tpl->set( 'yourdatakey', $yourdata );

    return true;
}
Swami-elevati (talkcontribs)

Thanks Florianschmidtwelzow, SkinTemplateOutputPageBeforeExec worked for me, but which parser hook should I use if I want to use cache the db result.

Florianschmidtwelzow (talkcontribs)

It depends on where you want to add the content of your function and what you want to add :) if you want to add short properties, maybe you can use ParserOutput::setProperty(). To find the best hooks for you, it's the best, if you read Manual:Hooks and look at the section Page rendering. Read the descriptions, when the hook get's called and what object's it provides and compare this with your needs :)

Swami-elevati (talkcontribs)

Cool. ParserOutput::setProperty() worked perfect for me. Thanks again for sharing this information

Reply to "Access extension function inside skin"