Jump to content

Template:Automatic category TOC/doc: Difference between revisions

From cernipedia
No edit summary
 
(8 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[Special:Contributions/37.63.229.217|37.63.229.217]] ([[User talk:37.63.229.217|talk]]) 12:43, 3 February 2025 (UTC){{Documentation subpage}}
{{Documentation subpage}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
{{High-use}}
{{High-use}}
Line 40: Line 40:


... but only if the transclusion is outside any {{tag|noinclude}} tags.
... but only if the transclusion is outside any {{tag|noinclude}} tags.
<small>{{Purge|''Purge this page to update the totals''}}</small>
== Bugs ==
== Bugs ==
This template uses the [[Help:Magic words|magic word]] <code><nowiki>{{PAGESINCATEGORY}}</nowiki></code> to count the number of pages in the category. Unfortunately, this function can return wildly erroneous results on some categories which have had many pages added and removed.
{{tracked|T221795}}
 
This template uses the [[Help:Magic words|magic word]] <code><nowiki>{{PAGESINCATEGORY}}</nowiki></code> to count the number of pages in the category. Due to caching, the results are occasionally inaccurate.  
This bug is well-known, and has been documented in several places since 2010, including:
* [[phab:T18036]]
* [[phab:T221795]]
* [[phab:T69196]]
 
In the overwhelming majority of categories, the count is recorded accurately enough to support use of this template.  However, there seemed to be some issue with <code><nowiki>{{PAGESINCATEGORY}}</nowiki></code> falsely returning zero in some cases. This is tracked in:
* {{clc|Automatic category TOC on pages where PAGESINCATEGORY returns zero}}


As of 19 April 2020, that problem seems to have been fixed by a [[Special:Diff/950933704/951919806|small but cunning tweak]] to how <code><nowiki>{{PAGESINCATEGORY}}</nowiki></code> is called.
== TemplateData ==
{{TemplateData header}}
<templatedata>
{
"params": {
"align": {
"description": "Aligns {{Category TOC}} to either the left or center, depending on the value.",
"type": "line",
"suggestedvalues": [
"left",
"center"
]
},
"top": {
"description": "If true, displays a link to the \"top\" of the table of contents.",
"type": "boolean"
},
"numerals": {
"description": "Specifies how numbers are included. \"group\" (default) generates one link for 0–9. \"separate\" generates one link per number. \"no\" hides numbers entirely. ",
"type": "line",
"suggestedvalues": [
"group",
"separate",
"no"
]
},
"uppercase": {
"description": "Specifies how uppercase letters are included. \"yes\" (default) generates generates one link per letter. \"group\" generates one link for all of A–Z. \"no\" hides uppercase letters entirely. ",
"type": "line",
"suggestedvalues": [
"yes",
"group",
"no"
]
},
"lowercase": {
"description": "Specifies how lowercase letters are included. \"no\" (default) hides lowercase letters entirely. \"yes\" generates generates one link per letter. \"group\" generates one link for all of a–z. ",
"type": "line",
"suggestedvalues": [
"yes",
"no",
"group"
]
}
},
"format": "inline",
"description": "Automatically displays the appropriate category table of contents depending on the size of a category. It takes a handful of parameters, but they only affect the display if {{Category TOC}} is the appropriate category TOC."
}
</templatedata>


The category <em>should</em> contain only pages labelled as "empty".
<small>{{Purge|''Purge this page to update the totals''}}</small>


== See also ==
== See also ==
Line 67: Line 102:
[[Category:Category header templates]]
[[Category:Category header templates]]
[[Category:Wikipedia category table of contents templates]]
[[Category:Wikipedia category table of contents templates]]
 
[[Category:Wikipedia Automatic category TOC]]
}}</includeonly>
}}</includeonly>

Latest revision as of 13:13, 19 November 2026

__EXPECTED_UNCONNECTED_PAGE__

Adds a Table of Contents (TOC) to a category page if the category's size warrants it.

The size thresholds are:

  1. <= 100 pages → no TOC
  2. 101–1200 pages → {{Category TOC}}
  3. > 1200 pages → {{Large category TOC}}

Usage

<syntaxhighlight inline lang="wikitext"></syntaxhighlight>

On category pages, {{Automatic category TOC}} can be placed wherever you want the TOC to be displayed.

On a category header template, it is best placed outside any <includeonly>...</includeonly> tags, so that the template is categorised as using this template.

Parameters

No parameters are needed.

However, the parameters available to {{Category TOC}} may be supplied, and if {{Automatic category TOC}} calls {{Category TOC}}, those parameters will be passed on to {{Category TOC}}.

So, for example, <syntaxhighlight inline lang="wikitext"></syntaxhighlight> will:

  1. Have no effect if no TOC is generated
  2. Align to the center if {{Category TOC}} is used
  3. Have no effect if {{Large category TOC}} is used, because {{Large category TOC}} accepts no parameters

Tracking

Effect Pages %
No TOC 0 Lua error: bad argument #1 to 'formatNum' (NaN).
Standard {{Category TOC}} 0 Lua error: bad argument #1 to 'formatNum' (NaN).
{{Large category TOC}} 0 Lua error: bad argument #1 to 'formatNum' (NaN).
Total 0
Purge this page to update the totals.

Each page using this template is categorised in one of three tracking categories:

Templates which transclude {{Automatic category TOC}} are categorised in

... but only if the transclusion is outside any <noinclude>...</noinclude> tags.

Bugs

This template uses the magic word {{PAGESINCATEGORY}} to count the number of pages in the category. Due to caching, the results are occasionally inaccurate.

TemplateData

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Automatic category TOC in articles based on its TemplateData.

TemplateData for Automatic category TOC

Automatically displays the appropriate category table of contents depending on the size of a category. It takes a handful of parameters, but they only affect the display if {{Category TOC}} is the appropriate category TOC.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
alignalign

Aligns {{Category TOC}} to either the left or center, depending on the value.

Suggested values
left center
Lineoptional
toptop

If true, displays a link to the "top" of the table of contents.

Booleanoptional
numeralsnumerals

Specifies how numbers are included. "group" (default) generates one link for 0–9. "separate" generates one link per number. "no" hides numbers entirely.

Suggested values
group separate no
Lineoptional
uppercaseuppercase

Specifies how uppercase letters are included. "yes" (default) generates generates one link per letter. "group" generates one link for all of A–Z. "no" hides uppercase letters entirely.

Suggested values
yes group no
Lineoptional
lowercaselowercase

Specifies how lowercase letters are included. "no" (default) hides lowercase letters entirely. "yes" generates generates one link per letter. "group" generates one link for all of a–z.

Suggested values
yes no group
Lineoptional


See also