Mediawiki Extension add Javascript in Header

前端 未结 2 1598
囚心锁ツ
囚心锁ツ 2020-12-21 11:05

Hi my problem is that i cant load some javascript file @ my special page extension. I tried it with addscript and some other methods but the only thing what happened was th

2条回答
  •  天命终不由人
    2020-12-21 11:49

    addScript works in version 1.16 and before. In 1.17 and later you should use addHeadItem:

    $wgHooks['ParserBeforeTidy'][] = 'wgAddJquery';
    
    function wgAddJquery(&$parser, &$text) {
    
      global $addJqueryScripts;
      if ($addJqueryScripts === true) return true;
    
      $parser->mOutput->addHeadItem(
        ''
      );
    
      $addJqueryScripts = true;
    
      return true;
    
    }
    

提交回复
热议问题