Extension:SearchParserFunction/ar
حالة الإصدار مستقر |
|
|---|---|
| تنفيذ | دوال المحلل اللغوي, البحث |
| بيان | Adds a parser function to search, format and display search results in wiki pages. |
| المؤلف/المؤلفون | Sophivorusنقاش |
| آخر إصدار | 2.1 |
| MediaWiki | >= 1.40.0 |
| تغييرات قاعدة البيانات | لا |
| Licence | رخصة جنو العمومية 3.0 أو ما بعدها |
| التنزيل | |
| مثال | Appropedia |
| ترجم الامتداد SearchParserFunction لو كان متوفرا على translatewiki.net | |
The SearchParserFunction extension adds a parser function to search, format and display search results in wiki pages.
Installation
- نزّل الملف/الملفات وضعها في دليل يحمل اسم
SearchParserFunctionداخل مجلد extensions/ لديك.
يجب على مطوري البرمجيات والمساهمين بالكود البرمجي تثبيت الامتداد من غت بدلا من ذلك، مستخدمين:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/SearchParserFunction
- أضف الكود التالي في الجزء الأسفل من ملف LocalSettings.php:
wfLoadExtension( 'SearchParserFunction' );
تم التنفيذ – اذهب إلى Special:Version على موقع الويكي لديك كي تتحقق من أن الامتداد قد ثبت بنجاح.
Usage
Basic usage
{{#search:foo}}
This will search for pages that contain foo and return the results as a list of links, like so:
You can use all available search operators. For example, if you're using CirrusSearch:
{{#search:foo incategory:"Bar" linksto:"Baz"}}
See المساعدة:CirrusSearch for all available search operators (or API:Search if you're not using CirrusSearch).
Parameters
| Name | Default | Description |
|---|---|---|
namespace |
0 | Namespace to search. Separate multiple values with commas. (See namespace constants.) |
limit |
10 | Max number of results, should be either an integer or 'max'. |
offset |
0 | Number of results to skip, useful to access results beyond the 'max' limit. |
profile |
Ranking algorithm to use, defaults to let the engine decide. | |
what |
'text'
|
Type of search to perform, either 'text', 'title' or 'nearmatch'.
'title' doesn't work when CirrusSearch is enabled (use intitle instead).
|
interwiki |
Include interwiki results in the search, if available. | |
rewrites |
Enable internal query rewriting, for example to correct spelling mistakes. | |
sort |
'relevance' |
Sorting criteria. |
format |
'list' |
Format of the search results. (See below for more.) |
For example, to get the name of the latest file that has foo in the title:
{{#search: foo
| namespace = 6
| limit = 1
| what = title
| sort = create_timestamp_asc
| format = plain
}}
Formats
List
Returns an unordered list (<ul>) of search results, linked to their pages.
For example:
Count
Returns the total number of search results as a plain number.
Plain
Returns a comma-separated list of plain titles. For example:
Foo, Bar, Baz
This format is designed for further processing. For example, using the #arraymap function of Extension:PageForms:
{{#arraymap: {{#search:foo}} | , | @ | [[@]] | <br> }}
This would output the search results one below the other and linked to their pages, like so:
If some of the titles contain commas, you can change the separator like so:
{{#search:foo|separator=;}}
JSON
Returns a JSON object for further processing, for example in a Lua module.
Note that this format returns the entire output from the Search API, not just the search results.
Template
Returns the search results wrapped in a template. The search result title is passed to the template as an unnamed parameter {{{1}}} and may be used or ignored.
For example, if a template named "Search result" contained the following:
<div style="border: 1px solid #aaa; border-radius: 10px; margin: 1em 0; padding: 1em; max-width: 600px;">
<span style="font-size:120%">[[{{{1}}}]]</span>
<p>{{fullurl:{{{1}}}}}</p>
</div>
then a query such as:
{{#search: foo
| format = template
| template = Search result
}}
would output something like this:
Hooks
SearchParserFunctionQuery
Use this hook to customize the query to the Search API.
SearchParserFunctionOutput
Use this hook to add or modify search result formats.
See also
- Extension:SemanticMediaWiki - أكثر تطوراً وقوة، ولكن أيضاً أكثر تعقيداً وصعوبة في الحفاظ عليه. #ask queries can do much than #search can't, but #search can also do some things that #ask can't, such as simple full-text search.
- أداة:DynamicPageList (ويكيميديا) - List pages by category and other criteria.
- Appropedia:Template:Search results - Real use case of this extension.
