Wikidane:Jak korzystać z danych w projektach Wikimedia
Dane z Wikidanych można wyświetlać bezpośrednio w projektach Wikimedia różnymi metodami. Dzięki funkcji parsera lub kodowi Lua możliwe jest wyświetlanie etykiet, opisów, wartości, odnośników i wielu innych informacji przechowywanych na Wikidanych. Aby zobaczyć przegląd zastosowań Wikidanych w projektach Wikimedia, zobacz Wikidata:Wikidata in Wikimedia projects.
Na tej stronie dowiesz się, jak korzystać z danych z Wikidanych na swojej wiki. Możesz także dowiedzieć się więcej o tym czym są Wikidane, jak zorganizowane są informacje lub przejrzeć słowniczek.
Czy mogę uzyskać dostęp do danych Wikidanych z mojej wiki?
Dwie główne funkcjonalności klienta, funkcja parsera i dostęp przez Lua, mogą być włączone razem na wiki w projektach Wikimedia. Jest tak obecnie w przypadku prawie wszystkich projektów Wikimedia.
Aby sprawdzić, czy te funkcjonalności są aktywne na wiki, możesz uzyskać dostęp do strony Special:Version
. Jeśli pojawiają się na liście „deklaracje” W sekcji „funkcje parsera”, oznacza to, że możesz użyć tego na swojej wiki.
Dostęp do danych Wikidanych jest obecnie ograniczony do projektów Wikimedia ze względu na ograniczenia techniczne. Jeśli masz własną instancję MediaWiki, nie możesz używać danych z Wikidanych przy użyciu tych funkcji. Możesz jednak skonfigurować własną instancję Wikibase i używać jej w ten sam sposób.
Funkcja parsera
Pierwszym sposobem uzyskania dostępu do danych jest użycie funkcji parsera #statements
. Ta funkcja pozwala wyświetlić wartość dowolnej deklaracji zawartej w elemencie.
Dostęp bezpośredni
On a page that is connected to a Wikidata item via the interwiki links, you can use the function by adding the label of the property you want in your language or the P-number of the property. The code has to be added in the wikicode.
Examples:
{{#statements:member of political party}}
or{{#statements:P102}}
will return the "member of political party" value.{{#statements:discoverer or inventor}}
or{{#statements:P61}}
will return the "discoverer or inventor" value.- On w:en:Douglas Adams, the code
{{#statements:country of citizenship}}
will display "United Kingdom".
Arbitrary access
You can also display data from an item that is not connected via an interwiki link. For this, you use the same function, adding a parameter from=
followed by the Q-id of the item.
Examples:
{{#statements:birth name|from=Q42}}
will display "Douglas Noël Adams"{{#statements:country of citizenship|from=Q42}}
will display "United Kingdom".{{#statements:P1476|from=Q191380}}
will display "Notre-Dame de Paris"{{#statements:author|from=Q191380}}
will display "Victor Hugo"{{#statements:publication date|from=Q191380}}
will display "1831"
Multiple values
When a statements has multiple values, the parser function will show the "best" value(s), which means:
- only show the preferred value(s) if there are any;
- if not, show all the values;
- but never the deprecated ones.
Where there are multiple values, they are shown in a comma-separated list.
Example: {{#statements:occupation|from=Q42}}
displays "playwright, screenwriter, novelist, children's writer, science fiction writer, comedian, writer, musician" (there are other occupations in Douglas Adams (Q42) but only some are preferred).
Sformatowane wartości
W przypadku niektórych właściwości funkcja parsera #statements wyświetli wartość w określonym formacie.
- Obrazy z Commons
Funkcja parsera wyświetla podgląd miniatury obrazu, zmieniając jego rozmiar na 200 pikseli. Linkuje do strony opisującej plik w Wikimedia Commons.
{{#statements:image|from=Q42}}
wyświetla
- Współrzędne geograficzne
Funkcja parsera wyświetla współrzędne w formacie stopni-minut-sekund.
{{#statements:coordinate location|from=Q243}}
wyświetla 48°51′30″N 2°17′40″E
- Monolingual text
Text values are displayed as they are, with no formatting.
{{#statements:motto text|from=Q95}}
wyświetla "Do the right thing".
- Data
Wartość daty zostanie sformatowana w formacie dzień-miesiąc-rok.
{{#statements:date of birth|from=Q42}}
wyświetla 11 March 1952
- Linki
Linki są klikalne.
{{#statements:official website|from=Q243}}
wyświetla https://www.toureiffel.paris, https://www.toureiffel.paris/en, https://www.toureiffel.paris/it
- Zewnętrzne identyfikatory
Zewnętrzny identyfikator dostarcza bezpośredni link do zewnętrznej strony internetowej.
{{#statements:IMDb ID|from=Q42}}
wyświetla nm0010930
- Elementy
{{#statements:capital|from=Q142}}
displays Paris
Raw value
To display the unlinked value, use #property
.
Przykład:
{{#property:IMDb ID|from=Q42}}
displays nm0010930
Moduły
Dostęp do danych można uzyskać również dzięki modułom Lua, które są znacznie bardziej elastyczne. Więcej informacji na temat korzystania z modułów znajduje się w w:Module:Wikidata#Usage.
For a full technical reference of Lua functions for accessing Wikidata, see mw:Extension:Wikibase Client/Lua.
Szablony
Some templates use modules to access Wikidata data. They are as simple to use as regular templates. Moreover, using Wikidata, some parameters become unnecessary. For instance, some infoboxes are able to retrieve data from Wikidata, so you just have to insert the template and all the data will magically appear (if the needed information is present on the Wikidata item, of course). For templates using Wikidata see Category:Templates using data from Wikidata (Q11985372).
If you want to create a template on your wiki, check your documentation page about Module:Wikidata and already existing templates.
Listy
Regularnie aktualizowane listy
Daily updated lists based on SPARQL queries can be configured using Template:Wikidata list (Q19860885). Content is replaced daily.
There are essentially two uses:
- Work lists: lists with topics to be covered in project namespace. Results can be limited to topics that don't exist.
- Reference list: lists for a specific topic in article namespace.
This is currently the most efficient way of doing lists.
Listy dynamiczne
Content is displayed from various items based on a selection done in a Lua module.
Listy manualne
A series of items are selected and their properties displayed in an article. Content from Wikidata can be completed with locally edited text.
Examples of use cases
Magic infobox
A call of the general cheese infobox template fr:Modèle:Infobox Fromage without any parameters, on an article about a type of cheese, for example fr:Reblochon, produces an infobox with details about that type of cheese, using data from the Wikidata item linked to the article.
Commons
Commons creator template uses Wikidata with arbitrary access to provide information about the creators of the works.
Graph
Authority model
Wikiźródła
Jak uzyskać pomoc?
You will find contributors on the Wikidata project chat which exists in different languages. Moreover, some wikis have projects dedicated to Wikidata : see Project:WikiProject Wikidata (Q20855878).
Zobacz też
- Module:Databox, a ready-made set of modules for building infoboxes
- Wikidata:Infobox Tutorial
- Help:Statements