Munurin millum rættingarnar hjá "Module:Category handler/doc"

Content deleted Content added
No edit summary
Xqbot (kjak | íkøst)
s Bot: Erstatt forældet <source> -tag og parameteren "enclose" [https://lists.wikimedia.org/pipermail/wikitech-ambassadors/2020-April/002284.html]
 
Linja 7:
 
For cases where a module only needs to categorise in one of the namespaces main (articles), file (images) or category, then using this module is overkill. Instead, you can simply get a title object using [[rev:https://www.mediawiki.org/wiki/Extension:Scribunto/Lua reference manual#mw.title.getCurrentTitle#mw.title.getCurrentTitle|mw.title.getCurrentTitle]] and check the <code>nsText</code> field. For example:
<sourcesyntaxhighlight lang="lua">
local title = mw.title.getCurrentTitle()
if title.nsText == 'File' then
-- do something
end
</syntaxhighlight>
</source>
However, if your module needs to categorize in any other namespace, then we recommend you use this module, since it provides proper category suppression and makes it easy to select how to categorize in the different namespaces.
 
Linja 32:
This module takes two or more parameters. Here's an example using a hello world program:
 
<sourcesyntaxhighlight lang="lua">
p = {}
local categoryHandler = require( 'Module:Category handler' ).main
Linja 47:
return p
</syntaxhighlight>
</source>
 
The above example uses the default settings for the category handler module. That means the example module will categorize on pages in the following namespaces:
Linja 64:
This module takes one or more parameters named after the different page types as listed in section [[#Namespaces|namespaces]] above. By using those parameters you can specify exactly in which namespaces your template should categorize. Like this:
 
<sourcesyntaxhighlight lang="lua">
p = {}
local categoryHandler = require( 'Module:Category handler' ).main
Linja 80:
return p
</syntaxhighlight>
</source>
 
The above module will only categorize in main and talk space. But it will not categorize on /archive pages since they are blacklisted. (See section [[#Blacklist|blacklist]] below.) And if you need to demonstrate (discuss) the module on a talkpage, then you can feed "<code>nocat='true'</code>" to prevent that template from categorizing. (See section [[#Nocat|nocat]] below.) Like this:
Linja 94:
Sometimes we want to use the same category in several namespaces, then do like this:
 
<sourcesyntaxhighlight lang="lua">
p = {}
local categoryHandler = require( 'Module:Category handler' ).main
Linja 114:
return p
</syntaxhighlight>
</source>
 
In the above example we use a numbered parameter to feed one of the categories, and then we tell this module to use that numbered parameter for both the help and user space.
Linja 126:
The category handler module also has a parameter called '''all'''. It works like this:
 
<sourcesyntaxhighlight lang="lua">
p = {}
local categoryHandler = require( 'Module:Category handler' ).main
Linja 141:
return p
</syntaxhighlight>
</source>
 
The above example will categorize in all namespaces, but not on blacklisted pages. If you want to demonstrate that module on a page, then use "<code>nocat=true</code>" to prevent the template from categorizing.
Linja 149:
The all parameter can also be combined with the rest of the parameters. Like this:
 
<sourcesyntaxhighlight lang="lua">
p = {}
local categoryHandler = require( 'Module:Category handler' ).main
Linja 166:
return p
</syntaxhighlight>
</source>
 
If the above module is placed on an article, then it will add the categories "Somecat1" and "Somecat2". But on all other types of pages it will instead add "Somecat1" and "Somecat3". As the example shows, the all parameter works independently of the rest of the parameters.
Linja 174:
The category handler module understands the '''subpage''' parameter. Like this:
 
<sourcesyntaxhighlight lang="lua">
p = {}
local categoryHandler = require( 'Module:Category handler' ).main
Linja 190:
return p
</syntaxhighlight>
</source>
 
If "<code>subpage='no'</code>" then this template will ''not'' categorize on subpages. For the rare occasion you ''only'' want to categorize on subpages, then use "<code>subpage='only'</code>". If '''subpage''' is empty or undefined then this template categorizes both on basepages and on subpages.
Linja 234:
Besides from categories, you can feed anything else to this module, for instance some text. Like this:
 
<sourcesyntaxhighlight lang="lua">
p = {}
local categoryHandler = require( 'Module:Category handler' ).main
Linja 250:
 
return p
</syntaxhighlight>
</source>
 
When the module code above is used on anything other than a talk page, it will look like this:
Linja 266:
For testing and demonstration purposes this module can take a parameter named '''page'''. Like this:
 
<sourcesyntaxhighlight lang="lua">
p = {}
local categoryHandler = require( 'Module:Category handler' ).main
Linja 281:
return p
</syntaxhighlight>
</source>
 
In the above code we on purpose left out the brackets around the category names so we see the output on the page. No matter on what kind of page the code above is used it will return this:
Linja 298:
You can make it so your module also understands the '''page''' parameter. That means you can test how your template will categorize on different pages, without having to actually edit those pages. Then do like this:
 
<sourcesyntaxhighlight lang="lua">
p = {}
local categoryHandler = require( 'Module:Category handler' ).main
Linja 313:
 
return p
</syntaxhighlight>
</source>
 
=== Parameters ===