MediaWiki/Suche: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 165: | Zeile 165: | ||
<div class="mw-collapsible-content">'''Antwort5'''</div> | <div class="mw-collapsible-content">'''Antwort5'''</div> | ||
</div> | </div> | ||
[[Kategorie:Wiki:Verwaltung]] |
Version vom 18. April 2022, 10:23 Uhr
topic kurze Beschreibung
Beschreibung
Installation
Syntax
Parameter
Optionen
Konfiguration
Dateien
Anwendungen
Default Namespaces
In MediaWiki sind alle Seiten Ihrer Site in verschiedene Namensräume gruppiert.
- Standardmäßig ist die Suchfunktion so konfiguriert, dass nur im Main-Namespace gesucht wird.
- Das ist der Namespace, der die Artikel enthält.
- Wenn also der Begriff oder die Phrase, nach der der Benutzer sucht, auf Seiten enthalten ist, die zu anderen Namensräumen gehören (z. B. Diskussionsseiten, Benutzerseiten usw.), werden diese Seiten nicht in den Suchergebnissen aufgeführt, es sei denn, die erweiterten Suchoptionen des Benutzers wählt gezielt andere Namespaces aus.
- Wenn Sie möchten, können Sie die Suchfunktion für andere Namensräume aktivieren.
- Sie möchten beispielsweise, dass mit Artikeln verknüpfte Diskussionsseiten und persönliche Benutzerseiten standardmäßig ebenfalls durchsucht werden.
- Dies können Sie mit Hilfe der Option $wgNamespacesToBeSearchedDefault tun.
- Sie müssen es am Ende der LocalSettings.php-Datei Ihres MediaWikis zusammen mit einer Liste der Namespaces hinzufügen.
Bearbeiten Sie also LocalSettings.php und fügen Sie am Ende der Datei Folgendes hinzu:
$wgNamespacesToBeSearchedDefault = array( NS_MAIN => true, NS_TALK => false, NS_USER => false, NS_USER_TALK => false, NS_PROJECT => false, NS_PROJECT_TALK => false, NS_FILE => false, NS_FILE_TALK => false, NS_MEDIAWIKI => false, NS_MEDIAWIKI_TALK => false, NS_TEMPLATE => false, NS_TEMPLATE_TALK => false, NS_HELP => false, NS_HELP_TALK => false, NS_CATEGORY => false, NS_CATEGORY_TALK => false );
- The namespaces are listed with their text IDs (also known as constants).
- By default, only NS_MAIN is set to true, which means that the search function works only with the Main namespace.
- For a complete list of the namespaces with their respective constants and what each namespace is used for check out the article with the reference list of MediaWiki namespaces with their ID numbers and constants.
- To set the search function to search the pages of a namespace simply change false with true for that namespace.
For example, if you want discussion pages associated with articles, personal user pages and their associated discussion pages and category pages to be searched, make sure you have the following in your LocalSettings.php file:
$wgNamespacesToBeSearchedDefault = array( NS_MAIN => true, NS_TALK => true, NS_USER => true, NS_USER_TALK => true, NS_PROJECT => false, NS_PROJECT_TALK => false, NS_FILE => false, NS_FILE_TALK => false, NS_MEDIAWIKI => false, NS_MEDIAWIKI_TALK => false, NS_TEMPLATE => false, NS_TEMPLATE_TALK => false, NS_HELP => false, NS_HELP_TALK => false, NS_CATEGORY => true, NS_CATEGORY_TALK => false );
- These changes apply to all users of the site, both unregistered and registered
- In MediaWiki versions 1.15 and older the changes will not affect existing registered users
- For such users you have to configure the options with the help of the script userOptions.php
- For more information on how to use it check out the article on how to edit the options of users in MediaWiki
- Note that the above changes set which namespaces should be automatically searched by default when the search function is used
- On the page with the search results on the frontend there are advanced options that can be viewed by clicking on the Advanced button
- It displays a list of the namespaces and the user can specifically select which namespaces they want to search
- This can be done regardless of which namespaces are set to be searched by default with the option $wgNamespacesToBeSearchedDefault
The LocalSettings.php file that you have to modify is in the root MediaWiki folder on your MediaWiki hosting account.
- If you have installed the application directly in the public_html directory on the account (making the frontend URL yourdomain.com), then the path to the file on the account with respect to that directory will be public_html/LocalSettings.php.
- An easy way for HostKnox customers to edit files on their accounts is with the File manager of the Pixie control panel.
- You can also download the file on your local computer (e.g. with an FTP client), edit it with a text editor (e.g. Notepad ++) and upload it back overwriting the old file.
$wgNamespacesToBeSearchedDefault = [ NS_MAIN => true, 2 => true, 3 => true, 10 => true, 11 => true, 184 => true, 185 => true, 186 => true, 187 => true, 188 => true, 189 => true, 190 => true, 191 => true, 192 => true, 193 => true, 194 => true, 195 => true, 196 => true, 197 => true, 198 => true, 199 => true, 200 => true, 201 => true, "_merge_strategy" => "array_plus" ];
Add all the numbered Namespaces and set to true just like in the Visual Editor
$wgNamespacesToBeSearchedDefault = [ NS_MAIN => true, NS_CATEGORY => true ]; $wgNamespacesToBeSearchedDefault=$nsAll
A number of Content: pages in my wiki have content in addition to serving as containers for sub-categories/pages. Even when setting the following in LocalSettings.php:
$wgNamespacesToBeSearchedDefault = [
NS_MAIN => true, NS_CATEGORY => true ]; executed from the searchbar fail to discover the sought-for content
- the Special:Search UI also fails to discover this content unless I manually click "Everything" instead of "Content" under the Special:Search text field.
Interestingly, I do get the behavior I want if I declare:
$wgNamespacesToBeSearchedDefault=$nsAll
- In which case searches from the search bar correctly discover all content (even though "$nsAll" itself is undefined at least within the scope of LocalSettings.php).
- The disadvantage here is that since "$nsAll" is undefined, runJob.php complains about "$nsAll" being an unknown variable.
- This doesn't appear to break runJob.php, but the whole affair seems messy, and I'd much prefer the wgNamespacesToBeSearchedDefault to work out of the box as advertised.
Sicherheit
Dokumentation
Projekt-Homepage
Links
Siehe auch
Weblinks
- https://www.mediawiki.org/wiki/Manual:$wgNamespacesToBeSearchedDefault
- https://www.hostknox.com/knowledgebase/679/How-to-select-the-default-namespaces-to-be-searched-by-the-search-function-in-MediaWiki.html
- https://workingwithmediawiki.com/book/chapter9.html
Einzelnachweise
Testfragen
Testfrage 1
Testfrage 2
Testfrage 3
Testfrage 4
Testfrage 5