Changes

2,678 bytes added ,  20:54, 15 July 2021
Pywikibot 6.4.0
This module produces hatnote saying "The main article for this category is x." It implements the {{tl|cat main}} template.

== Use from wikitext ==

This module should usually be used via the {{tl|cat main}} template. However, it can also be used from #invoke with the syntax <code><nowiki>{{#invoke:Cat main|catMain|</nowiki>''parameters''<nowiki>}}</nowiki></code>. Please see the {{tl|cat main}} template documentation for available parameters.

== Use from other Lua modules ==

Load the module:

<syntaxhighlight lang="lua">
local mCatMain = require('Module:Cat main')
</syntaxhighlight>

You can then use the _catMain function like this:

<syntaxhighlight lang="lua">
mCatMain._catMain(options, ...)
</syntaxhighlight>

<var>options</var> is an optional table that can be used to configure the function's output. There are two available options, "article" and "selfref".
* '''article''' - if this is set to false, "no", "n", "false", or 0, the module outputs "The main page" rather than "The main article". Use the code {{code|1={article = false}|2=lua}}.
* '''selfref''' - this is used when the output is a self-reference to Wikipedia. To set this option, use {{code|1={selfref = true}|2=lua}}. (See the {{tl|selfref}} template for more details on self-references.)

The remaining arguments are page names to be turned into link(s) following the text "The main article for this category is". If no page names are specified, the current page name (minus the [[WP:NS|namespace]] name) is used for the first link.

; Example 1
<syntaxhighlight lang="lua">
mCatMain._catMain(nil, 'Foo')
</syntaxhighlight>
Produces:
:<code><nowiki><div class="hatnote relarticle mainarticle">The main article for this [[Help:Categories|category]] is '''[[Foo]]'''.</div></nowiki></code>
Displays as:
{{cat main|Foo}}

; Example 2
<syntaxhighlight lang="lua">
mCatMain._catMain(nil, 'Foo', 'Bar', 'Baz')
</syntaxhighlight>
Produces:
:<code><nowiki><div class="hatnote relarticle mainarticle">The main articles for this [[Help:Categories|category]] are '''[[Foo]]''', '''[[Bar]]''' and '''[[Baz]]'''.</div></nowiki></code>
Displays as:
{{cat main|Foo|Bar|Baz}}

; Example 3
<syntaxhighlight lang="lua">
mCatMain._catMain({article = false}, 'Foo')
</syntaxhighlight>
Produces:
:<code><nowiki><div class="hatnote relarticle mainarticle">The main page for this [[Help:Categories|category]] is '''[[Foo]]'''.</div></nowiki></code>
Displays as:
{{cat main|Foo|article=no}}

== Technical details ==

This module uses [[Module:Hatnote]] to format the hatnote text.

<includeonly>{{sandbox other||
<!-- Categories go here and interwikis go in Wikidata. -->
[[Category:Hatnote modules]]
}}</includeonly>