You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MediaWiki 1.26自定义皮肤搜索表单自动补全功能失效求助

Hey there, let's troubleshoot why the search autocomplete isn't working in your custom MediaWiki 1.26 skin. I've tackled similar issues before, so here are the key checks and fixes to try out:

Fixing Search Autocomplete in Custom MediaWiki 1.26 Skins
  • Make sure required JavaScript modules are loaded
    MediaWiki's search autocomplete relies on the mediawiki.searchSuggest module, which bundles jQuery UI Autocomplete and the necessary wiki-specific logic. In your skin's PHP code (usually in the initPage method of your skin class), add this line to load the module:

    $this->getOutput()->addModules( 'mediawiki.searchSuggest' );
    

    Don't skip this—without the right JS, autocomplete can't function at all.

  • Verify the search input's HTML attributes
    When using makeSearchInput, double-check the generated HTML (via your browser's "View Page Source") to ensure the input has the correct identifiers and flags. It should look something like this:

    <input type="search" name="search" id="searchInput" class="mw-searchInput" data-autocomplete="true">
    

    If your custom template is overriding or removing attributes like id="searchInput" or data-autocomplete="true", the autocomplete script won't be able to find and bind to the input.

  • Check if the OpenSearch API is working
    Autocomplete pulls suggestions via MediaWiki's API endpoint. Test this directly by visiting your-wiki-domain/api.php?action=opensearch&search=test in your browser—you should get a JSON response with search suggestions. If this fails:

    • Confirm $wgEnableOpenSearch = true; is set in your LocalSettings.php (it's enabled by default in 1.26, but worth checking).
    • Make sure your wiki's API isn't restricted by permissions or firewall rules.
  • Rule out JavaScript conflicts
    Custom skins often bring in external JS or jQuery versions that clash with MediaWiki's built-in scripts. Open your browser's developer console (F12 > Console tab) and look for errors like:

    • jQuery is not defined
    • $(...).autocomplete is not a function
      If you see these, ensure MediaWiki's jQuery loads before your custom JS, and avoid overwriting the global jQuery or $ variables.
  • Validate the search form structure
    The search input needs to be wrapped in a properly configured form pointing to Special:Search. Use makeSearchInput alongside makeSearchButton to ensure the structure is correct:

    <form action="<?php echo $this->getTitle( 'Special:Search' )->getLocalURL(); ?>" method="get" class="mw-search-form">
        <?php echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?>
        <?php echo $this->makeSearchButton( 'go' ); ?>
    </form>
    

    The mw-search-form class helps MediaWiki's scripts target the form correctly—don't omit it unless you're explicitly handling the binding yourself.

  • Clear MediaWiki's cache
    MediaWiki's caching can sometimes prevent new resources from loading. Purge the cache by:

    • Adding ?action=purge to the end of your wiki's URL and reloading.
    • Deleting files in your wiki's cache directory (if you have server access).

If you've tried all these steps and still have issues, sharing snippets of your skin's PHP code and the generated HTML for the search form would help narrow down the problem further.

内容的提问来源于stack exchange,提问作者Jose

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:50:42