Module:Sports rbr table
![]() | This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
![]() | 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 14,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. |
![]() | This module depends on the following other modules: |
![]() | This module uses TemplateStyles: |
Usage
Position tables
{{#invoke:Sports rbr table|table
| sortable = <!-- y or n or omit -->
| team1 =
| pos1 = <!-- 1 / 2 / 3 / 4 / ... -->
| team2 =
| pos2 = <!-- 1 / 2 / 3 / 4 / ... -->
<!-- ... -->
| color_1 = 1st
| text_1 = 1st place
| source =
}}
WDL tables
{{#invoke:Sports rbr table|table
| sortable = <!-- y or n or omit -->
| team1 =
| res1 = <!-- W / D / L ... -->
| team2 =
| res2 = <!-- W / D / L ... -->
<!-- ... -->
| color_W = green2
| color_D = yellow2
| color_L = red2
| source =
}}
Style
The XXX
in style=XXX
is to be replaced by one of the following available styles:
- matchup – for tables showing matchups and head-to-head results
Parameters
General parameters | |
---|---|
Parameter | Description |
title |
A top caption for the table, omit for no title. |
sortable |
Is the table sortable? Set to y for a sortable table, and omit for unsortable.
|
color_X |
The background color for position X . Here, X can be a single number (e.g., 1 for position 1), or a non-numeric value corresponding to a position used in the table (e.g., R for relegated or W for withdrew ...) See the color section below for more information on color syntax.
|
color_-3 |
The background color for position 1, 2, and 3. See the color section below for more information on color syntax. |
color_15- |
The background color for position 15, 16, .... See the color section below for more information on color syntax. |
text_Y |
Legend text for color_Y . Adding any legend text will trigger the inclusion of a legend at the bottom of the table.
|
source |
Source for the information in the table. |
notes |
Any additional notes at add to the foot of the table. |
update start_date |
Date of the last round of matches included in the table. If the table is complete, use |update=complete . If the matches will occur at a future date, use |update=future and |start_date= for the date of the first round of matches.
|
legendpos |
Position for the legend. Supported values include tr (top right), br (bottom right), tl (top left), bl (bottom left), t (top), and b (bottom).
|
legendorder |
The order for the entries in the legend (e.g., |legendorder=W/D/L ).
|
toptext |
Text to include at the top of the table. This is useful when |legendpos=tr and you wish to have the legend float next to text at the top.
|
header |
Text for the team column header. The default is Team ╲ Round .
|
labelalign |
Alignment for the column labels. The default is left .
|
firstround |
The number of the first round. The default is 1 .
|
rnd1 |
Text to use for the label for round 1. The default is 1 .
|
splitN |
A line can be added between section of the table (if desired) by adding |splitN=yes with N the position below which the bar should be shown.
|
Compact syntax | |
Parameter | Description |
team1 |
The wikilinked name of the first team. For additional teams, use team2 , team3 , ... For a temporary place holder, use |team1=- or |team1= or |team1=  or |team1=TBA .
|
pos1 |
The forward slash (/ ) delimited list of round-by-round positions for the first team. For example, |pos1=1/2/3/8/3/2/1 for seven rounds with the position changing from 1 to 2 to 3 to 8 to 3 to 2 to 1.
|
pos1_rnd3_note |
A footnote to append the 3rd position in the pos1 positions.
|
res1 |
The forward slash (/ ) delimited list of match results for the first team. For example, |res1=W/D/D/W/L for five rounds with the round-by-round results of win, draw, draw, win, loss. Note, this parameter cannot be used if |pos1= is being used.
|
res1_rnd3_note |
A footnote to append the 3rd result in the res1 match results.
|
Sports table syntax | |
Parameter | Description |
team1 |
this can be abbreviation for the first team. The remainder of the documentation in this section assumes the abbreviation is ABC . For additional teams, use team2 , team3 , ...
|
name_ABC |
The wikilinked name of team ABC
|
pos_ABC |
The forward slash (/ ) delimited list of round-by-round positions for team ABC . For example, |pos_ABC=1/2/3/8/3/2/1 for seven rounds with the position changing from 1 to 2 to 3 to 8 to 3 to 2 to 1.
|
res_ABC |
The forward slash (/ ) delimited list of match results for team ABC . For example, |res_ABC=W/D/D/W/L for five rounds with the round-by-round results of win, draw, draw, win, loss. Note, this parameter cannot be used if |pos_ABC= is being used.
|
Color
The module has several preset background colors that have acceptable contrast with black foreground text. It is recommended to use one of these colors, which match colors used by Module:Sports table.
Name | Hex value |
---|---|
green1 | BBF3BB |
green2 | CCF9CC |
green3 | DDFCDD |
green4 | EEFFEE |
blue1 | BBF3FF |
blue2 | CCF9FF |
blue3 | DDFCFF |
blue4 | EEFFFF |
Name | Hex value |
---|---|
yellow1 | FFFFBB |
yellow2 | FFFFCC |
yellow3 | FFFFDD |
yellow4 | FFFFEE |
red1 | FFBBBB |
red2 | FFCCCC |
red3 | FFDDDD |
red4 | FFEEEE |
Name | Hex value |
---|---|
black1 | BBBBBB |
black2 | CCCCCC |
black3 | DDDDDD |
black4 | EEEEEE |
1st | FFD700 |
2nd | C0C0C0 |
3rd | CC9966 |
In some rare cases, it may be necessary to override the background color for a particular cell. This can be accomplished using |posX_rndY_color=
or |resX_rndY_color=
where X
is the row number, and Y
is the round number.
Examples
Example 1: Compact positions syntax
Script error: The module returned a nil value. It is supposed to return an export table.
{{#invoke:Sports rbr table|table
| title = Example 1
| sortable = y
| team1 = A Team
| pos1 = 1/2/2/2/2
| team2 = B Team
| pos2 = 2/1/4/4/4
| team3 = C Team
| pos3 = 3/4/1/6/1
| team4 = D Team
| pos4 = 4/3/6/1/3
| team5 = E Team
| pos5 = 5/6/3/8/7
| team6 = F Team
| pos6 = 6/5/8/3/5
| team7 = G Team
| pos7 = 7/8/5/5/8
| team8 = H Team
| pos8 = 8/7/7/7/6
| color_1 = 1st
| text_1 = First place
| color_2 = green1
| text_2 = Promoted
| color_3-4 = blue2
| text_3-4 = Championship League
| color_7- = red1
| text_7- = Relegated
| source = Some source
}}
Example 2: Sports table positions syntax
Script error: The module returned a nil value. It is supposed to return an export table.
{{#invoke:Sports rbr table|table
| title = Example 2
| sortable = y
| team1 = AAA | team2 = BBB | team3 = CCC | team4 = DDD
| team5 = EEE | team6 = FFF | team7 = GGG | team8 = HHH
| name_AAA = A Team
| pos_AAA = 1/2/2/2/2
| name_BBB = B Team
| pos_BBB = 2/1/4/4/4
| name_CCC = C Team
| pos_CCC = 3/4/1/6/1
| name_DDD = D Team
| pos_DDD = 4/3/6/1/3
| name_EEE = E Team
| pos_EEE = 5/6/3/8/7
| name_FFF = F Team
| pos_FFF = 6/5/8/3/5
| name_GGG = G Team
| pos_GGG = 7/8/5/5/8
| name_HHH = H Team
| pos_HHH = 8/7/7/7/6
| color_1 = 1st
| text_1 = First place
| color_2 = green1
| text_2 = Promoted
| color_3-4 = blue2
| text_3-4 = Championship League
| color_7- = red1
| text_7- = Relegated
| source = Some source
}}
Example 3: Team combined table
Script error: The module returned a nil value. It is supposed to return an export table.
{{#invoke:sports rbr table|table
|title=Example 3
|header=Round
|label1= Ground
| res1= H/ A/ A/ H/ A/ H/ A/ H/ H/ A/ A/ H/ H/ A/ H/ A/ A/ H/ H/ A/ A
|label2= Result
| res2= W/ L/ L/ W/ W/ D/ W/ L/ L/ L/ L/ W/ W/ W/ W/ L/ D/ L/ L/ D/ L
|label3= Position
| pos3= 4/10/14/ 8/ 6/ 7/ 7/ 8/ 9/10/11/11/ 8/ 7/ 6/ 6/ 6/ 7/ 9/ 9/ 9
| color_W = green2| color_D = yellow2| color_L = red2
| color_1=green1| color_2=green2| color_3-4=green3
| color_5-7=blue1| color_18-=red1
| source = Some source
}}
Example 4: Team combined table with a legend
Script error: The module returned a nil value. It is supposed to return an export table.
{{#invoke:sports rbr table|table|legendpos=b
|title=Example 4
|header=Round
|label1= Ground
| res1= H/ A/ A/ H/ A/ H/ A/ H/ H/ A/ A/ H/ H/ A/ H/ A/ A/ H/ H/ A/ A
|label2= Result
| res2= W/ L/ L/ W/ W/ D/ W/ L/ L/ L/ L/ W/ W/ W/ W/ L/ D/ L/ L/ D/ L
|label3= Position
| pos3= 4/10/14/ 8/ 6/ 7/ 7/ 8/ 9/10/11/11/ 8/ 7/ 6/ 6/ 6/ 7/ 9/ 9/ 9
<!-- -->
| color_W = green2|text_W=Win
| color_D = yellow2|text_D=Draw
| color_L = red2|text_L=Loss
| text_H = Home|text_A = Away
| color_1=green1| color_2=green2| color_3-4=green3
| color_5-7=blue1| color_18-=red1
| source = Some source
}}
See also
Tracking category
- Category:Pages using sports rbr table with dubious updated parameter (87) (pages where the updated date does not match the parent page name)
- Category:Pages using sports rbr table with legendorder (173) (pages where the
|legendorder=
parameter is used) - Category:Pages using sports rbr table with rnd parameters (0) (pages where the
|rnd1=
parameter is used and may be converted to|firstround=
) - Category:Pages using sports rbr table with unsupported parameters (1) (pages where unsupported parameters are used, or where the
|header=
is potentially missing) - Category:Pages using sports rbr table with conflicting parameters (0)
- Category:Pages using sports rbr table with an undescribed result (1,024)
- Category:Pages using sports rbr table with an unusual source (21)
- Category:Pages using sports rbr table with unequal row lengths (887)
- Category:Pages using sports rbr table with per team and round coloring (0)
-- This module implements {{Sports rbr table}}
local p = {}
local function isnotempty(s)
return s and s:match( '^%s*(.-)%s*$' ) ~= ''
end
local args = nil
local color_map = {
green1='#BBF3BB', green2='#CCF9CC', green3='#DDFCDD', green4='#EEFFEE',
blue1='#BBF3FF', blue2='#CCF9FF', blue3='#DDFCFF', blue4='#EEFFFF',
yellow1='#FFFFBB', yellow2='#FFFFCC', yellow3='#FFFFDD', yellow4='#FFFFEE',
red1='#FFBBBB', red2='#FFCCCC', red3='#FFDDDD', red4='#FFEEEE',
black1='#BBBBBB', black2='#CCCCCC', black3='#DDDDDD', black4='#EEEEEE',
gold='#FFD700', silver='#C0C0C0', bronze='#CC9966'
}
local function get_color(p)
local c = args['color_' .. p]
if c then
return color_map[c] or c
end
p = tonumber(p or '0') or 0
if p <= 0 then
return nil
end
return nil
end
function p.table(frame)
args = getArgs(frame, {wrappers = {'Template:Sports rbr table'}})
local rounds = tonumber(args['rounds'] or '0') or 0
local firstround = tonumber(args['firstround'] or 1) or 1
local sortable = args['sortable'] and true or false
-- Adjust rounds
rounds = rounds - (firstround - 1)
-- Create the list of teams and positions
local team_list = {}
local pos_list = {}
local teams = 0
local maxrounds = 0
while args['team' .. (teams+1)] ~= nil do
teams = teams + 1
team_list[teams] = args['team' .. teams]
pos_list[teams] = mw.text.gsplit(args['pos' .. teams] or '', '%s*[/~]%s*')
maxrounds = (#result_list[teams] > maxrounds) and #result_list[teams] or maxrounds
end
maxrounds = (rounds > maxrounds) and rounds or maxrounds
local fs = 95
if ((maxrounds - firstround) > 37 ) then
fs = fs - 2*(maxrounds - firstround - 37)
end
-- Build the table
local root = mw.html.create('table')
root:addClass('wikitable')
root:addClass(sortable and 'sortable' or nil)
root:css('font-size', fs .. '%')
root:css('text-align', 'center')
-- Heading row
local row = root:tag('tr')
row:tag('th')
:attr('rowspan', args['sortable'] and 2 or nil)
:wikitext(args['header'] or 'Team ╲ Round')
for r=1,maxrounds do
row:tag('th')
:css('width', '15px')
:css('border-bottom', args['sortable'] and 'none' or nil)
:wikitext(r + (firstround - 1))
end
if args['sortable'] then
for r=1,maxrounds do
row:tag('th')
:css('height', '1.2ex')
:css('border-top', 'none')
end
end
-- Team positions
for t=1,teams do
row = root:tag('tr')
row:tag('td'):wikitext(team_list[t])
local pos = pos_list[t]
for r=1,maxrounds do
row:tag('td')
:css('background-color', get_color(pos[r]))
:wikitext(pos[r])
end
end
return tostring(root)
end