Bücher online kostenlos Kostenlos Online Lesen
Working With MediaWiki

Working With MediaWiki

Titel: Working With MediaWiki Kostenlos Bücher Online Lesen
Autoren: Yaron Koren
Vom Netzwerk:
they’re placed on the bottom of the page and contain a known language code as their interwiki alias, will automatically turn into helpful links in the sidebar to the article’s equivalents in other languages. (These are actually referred to as “interlanguage links”.) If you want to set up this capability on your wiki — if you have a Wikipedia-style setup, with multiple wikis for the same content in different languages — you can do that by adding the following to LocalSettings.php:
$wgInterwikiMagic = true;
$wgHideInterlanguageLinks = false;

Templates
    Templates are an integral part of the MediaWiki system. Technically, they’re nothing more than pages that can substitute in values when they’re transcluded, but that simple functionality opens up a world of possibilities. Templates are all stored in the “Template:” namespace (namespaces are described here ). At their most basic, templates can simply be a piece of text. For instance, you could have a perfectly valid template called “Hello”, whose page, located at “Template:Hello”, contains just the following text:
Hello, everybody!
    Once that page was created, you could put the following text anywhere in any wiki page:
{{Hello}}
    Placing double curly brackets around a text makes MediaWiki look for a template with that name, and then place its contents on the page if the template is found. In this case, the call would be replaced by the text “Hello, everybody!”.
    Here’s an example of a more complex template, “Needs work”, which looks more like the way templates in MediaWiki usually work. The “Needs work” template is meant to provide a simple way for users to tag pages that have problems. On the page “Template:Needs work”, we could have the following code:

This is the "Needs work" template. You can pass to it the field "Problem".


This page needs work, for the following reasons(s): {{{Problem|}}}.


    Let’s go through this code.The

tag is meant to hold text that is only displayed when users look at the template page itself; it should be text that describes the template. The

tag, on the other hand, holds text that will only be displayed on the page where the template is transcluded/called. Neither tag is necessary (though they’re both recommended); and any text not contained in either tag will be displayed both on the template page and on pages in which it’s called. Thus, the page "Template:Needs work" would display just this:
This is the "Needs work" template. You can pass to it the field "Problem".
    A user, seeing a page that needed work, could add a call to the "Needs work" template to the top of such a page, so it looks like this:
{{Needs work|Problem=Incorrect information}}
A bat is a kind of bug that lives in caves. It has glowing eyes that can shoot lasers!
    The page would then get displayed as:

This page needs work, for the following reasons(s): Incorrect information.

A bat is a kind of bug that lives in caves. It has glowing eyes that can shoot lasers!
    The value or values passed in to the template are substituted into the corresponding parameters defined in the template’s code. Parameters are specified using three curly brackets. Why does the template contain the string "
{{{Problem|}}}
" and not just "
{{{Problem}}}
"? That’s because MediaWiki has the unfortunate default behavior of literally displaying parameter strings if values aren’t passed in to them. So, if the template contained simply "
{{{Problem}}}
", and the template call looked like "
{{Needs work}}
" (i.e., with no values), the call would get displayed as:

This page needs work, for the following reasons(s): {{{Problem}}}.

    The pipe placed at the end tells MediaWiki to display an alternate string if the parameter isn’t set: in this case, nothing. You could also use the pipe to display alternate text: if the parameter tag looked like “
{{{Problem|Unknown}}}
", then a plain call to the "Needs work" template would display this:

This page needs work, for the following reasons(s): Unknown

    Templates can also have unnamed parameters; these are defined by their index, i.e. their order in the set of parameters, starting with 1. Let’s take a simple (and rather pointless) example, a template called "Painting" whose relevant section is this:
{{{1|}}} is a painting by {{{2|}}}./
    A call that looked

Weitere Kostenlose Bücher