Jump to content

Topic on Extension talk:AdvancedSearch

How to set a custom namespace preset as default

3
Summary by Thiemo Kreuz (WMDE)
Krabina (talkcontribs)

I could not find any documentation on how to set a custom made namespace preset as default. I was able to set a custom namespace preset, but "Default" will always be the one checked by default. User have to manually select the new one every time.

Krabina (talkcontribs)

Furthermore, the labeling does not work. I set

$wgAdvancedSearchNamespacePresets = [
        'preset-kma' => [
                'enabled' => true, // indication that this preset should be shown to the user
                'namespaces' => [ '0', '2', '6', '12', '14' ], // list of namespaces to include in this preset
                'label' => 'advancedsearch-namespaces-preset-kma' // id of the translation to use to label the prese>
        ],
];

Which works, but setting the File "MediaWiki:Advancedsearch-namespaces-preset-kma" does not display the label

Thiemo Kreuz (WMDE) (talkcontribs)

I think you are looking for $wgNamespacesToBeSearchedDefault. You probably don't even need a custom preset when you use this instead.

In case you end with two defaults – your new one and the build-in one – add 'defaultNamespaces' => [ 'enabled' => false ], to your $wgAdvancedSearchNamespacePresets configuration to remove the build-in default.

The problem with the label turns out to be an oversight. At the moment only some pre-defined messages can be used. I don't think this limitation is intentional and created phab:T352204 to fix it. Thanks a lot for reporting this!

Reply to "How to set a custom namespace preset as default"