Module:Large category TOC
Appearance
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This Lua module is used on approximately 11,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
Usage
This module implements Template:Large category TOC and similar templates. It is used on categories with many members to provide a means of indexing them by first letter and first two letters
For full lists (Template:Large category TOC):
{{#invoke:Large category TOC|aejot}}
For collapsible lists (Template:Collapsible large category TOC):
{{#invoke:Large category TOC|collapsible}}
-- Implements [[Template:Large Category TOC]]
local p = {}
local azupper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
local azlower = 'abcdefghijklmnopqrstuvwxyz'
function p.make(frame)
local pageurl = frame:preprocess('{{fullurl:{{FULLPAGENAME}}}}')
local toc = frame:preprocess('{{MediaWiki:Toc}}')
local title = '<div style="width:100%;">\n<span class="plainlinks">'..toc..':\n['..pageurl..' Top]'..
'\n['..pageurl..'?from=0 0-9]'
for i=1,26,1 do
local letter = string.sub(azupper,i,i)
title = title..'\n['..pageurl..'?from='..letter..' '..letter..']'
end
title = title..'\n</span>\n</div>'
local list = '<div style="overflow-x:auto; overflow-y:hidden; width:98%;"><span class="plainlinks">'..
'\n['..pageurl..'?from=* *] •'
local function atoz(letter)
local azlist = '\n• <b>'..letter..'</b> '
for i=1,26,1 do
local lowerletter = string.sub(azlower,i,i)
azlist = azlist..'\n['..pageurl..'?from='..letter..lowerletter..' '..letter..lowerletter..'] '
end
return azlist
end
for i=0,9,1 do
list = list..'\n['..pageurl..'?from='..i..' '..i..']'
end
for i=1,26,1 do
local letter = string.sub(azupper,i,i)
list = list..atoz(letter)
end
list = list..'\n</span></div>'
return frame:expandTemplate{title='Navigation bar',args={color='#f9f9f9;',title=title,list=list}}
end
return p