Module:PHL sports overall tally

From blackwiki
Jump to navigation Jump to search

About this module

This module is used to list the current or final overall team standings of the University Athletic Association of the Philippines (UAAP) and the National Collegiate Athletic Association (NCAA) of both seniors' and juniors' divisions.

Blank version

The below template contains a condensed version of the template with ALL teams' three-letter codes included, grouped by league and division. Omit parameters that are not needed.

University Athletic Association of the Philippines (UAAP)
{{#invoke:PHL sports overall tally|main|final=n

|team1 = ADU
|team2 = ADM
|team3 = DLS |j_short_DLS = DLSZ
|team4 = FEU |j_short_FEU = FEU-D
|team5 = NUI |j_short_NUI = NSNU
|team6 = UEA
|team7 = UPD |j_short_UPD = UPIS
|team8 = UST

<!-- Basketball (BSKB) -->
|m_BSKB_ADU =  |w_BSKB_ADU =  |b_BSKB_ADU =  |d_g_BSKB_ADU = 
|m_BSKB_ADM =  |w_BSKB_ADM =  |b_BSKB_ADM =  |d_g_BSKB_ADM = 
|m_BSKB_DLS =  |w_BSKB_DLS =  |b_BSKB_DLS =  |d_g_BSKB_DLS = 
|m_BSKB_FEU =  |w_BSKB_FEU =  |b_BSKB_FEU = 
|m_BSKB_NUI =  |w_BSKB_NUI =  |b_BSKB_NUI = 
|m_BSKB_UEA =  |w_BSKB_UEA =  |b_BSKB_UEA = 
|m_BSKB_UPD =  |w_BSKB_UPD =  |b_BSKB_UPD = 
|m_BSKB_UST =  |w_BSKB_UST =  |b_BSKB_UST =  |d_g_BSKB_UST = 

<!-- 3x3 basketball (3X3B) -->
|m_3X3B_ADU =  |w_3X3B_ADU = 
|m_3X3B_ADM =  |w_3X3B_ADM = 
|m_3X3B_DLS =  |w_3X3B_DLS = 
|m_3X3B_FEU =  |w_3X3B_FEU = 
|m_3X3B_NUI =  |w_3X3B_NUI = 
|m_3X3B_UEA =  |w_3X3B_UEA = 
|m_3X3B_UPD =  |w_3X3B_UPD = 
|m_3X3B_UST =  |w_3X3B_UST = 

<!-- Indoor volleyball (INVB) -->
|m_INVB_ADU =  |w_INVB_ADU = |b_INVB_ADU =  |g_INVB_ADU = 
|m_INVB_ADM =  |w_INVB_ADM = |b_INVB_ADM =  |g_INVB_ADM = 
|m_INVB_DLS =  |w_INVB_DLS = |b_INVB_DLS =  |g_INVB_DLS = 
|m_INVB_FEU =  |w_INVB_FEU = |b_INVB_FEU =  |g_INVB_FEU = 
|m_INVB_NUI =  |w_INVB_NUI = |b_INVB_NUI =  |g_INVB_NUI = 
|m_INVB_UEA =  |w_INVB_UEA = |b_INVB_UEA =  |g_INVB_UEA = 
|m_INVB_UPD =  |w_INVB_UPD = |b_INVB_UPD =  |g_INVB_UPD = 
|m_INVB_UST =  |w_INVB_UST = |b_INVB_UST =  |g_INVB_UST = 

<!-- Beach volleyball (BCVB) -->
|m_BCVB_ADU =  |w_BCVB_ADU = 
|m_BCVB_ADM =  |w_BCVB_ADM = 
|m_BCVB_DLS =  |w_BCVB_DLS = 
|m_BCVB_FEU =  |w_BCVB_FEU = 
|m_BCVB_NUI =  |w_BCVB_NUI = 
|m_BCVB_UEA =  |w_BCVB_UEA = 
|m_BCVB_UPD =  |w_BCVB_UPD = 
|m_BCVB_UST =  |w_BCVB_UST = 

<!-- Swimming (SWMM) -->
|m_SWMM_ADU =  |w_SWMM_ADU =  |b_SWMM_ADU =  |g_SWMM_ADU = 
|m_SWMM_ADM =  |w_SWMM_ADM =  |b_SWMM_ADM =  |g_SWMM_ADM = 
|m_SWMM_DLS =  |w_SWMM_DLS =  |b_SWMM_DLS =  |g_SWMM_DLS = 
|m_SWMM_FEU =  |w_SWMM_FEU =  |b_SWMM_FEU =  |g_SWMM_FEU = 
|m_SWMM_NUI =  |w_SWMM_NUI =  |b_SWMM_NUI =  |g_SWMM_NUI = 
|m_SWMM_UEA =  |w_SWMM_UEA =  |b_SWMM_UEA =  |g_SWMM_UEA = 
|m_SWMM_UPD =  |w_SWMM_UPD =  |b_SWMM_UPD =  |g_SWMM_UPD = 
|m_SWMM_UST =  |w_SWMM_UST =  |b_SWMM_UST =  |g_SWMM_UST = 

<!-- Chess (CHSS) -->
|m_CHSS_ADU =  |w_CHSS_ADU =  |b_CHSS_ADU =  |g_CHSS_ADU = 
|m_CHSS_ADM =  |w_CHSS_ADM =  |b_CHSS_ADM =  |g_CHSS_ADM = 
|m_CHSS_DLS =  |w_CHSS_DLS =  |b_CHSS_DLS =  |g_CHSS_DLS = 
|m_CHSS_FEU =  |w_CHSS_FEU =  |b_CHSS_FEU =  |g_CHSS_FEU = 
|m_CHSS_NUI =  |w_CHSS_NUI =  |b_CHSS_NUI =  |g_CHSS_NUI = 
|m_CHSS_UEA =  |w_CHSS_UEA =  |b_CHSS_UEA =  |g_CHSS_UEA = 
|m_CHSS_UPD =  |w_CHSS_UPD =  |b_CHSS_UPD =  |g_CHSS_UPD = 
|m_CHSS_UST =  |w_CHSS_UST =  |b_CHSS_UST =  |g_CHSS_UST = 

<!-- Tennis (TNNS) -->
|m_TNNS_ADU =  |w_TNNS_ADU =  |b_TNNS_ADU =  |g_TNNS_ADU = 
|m_TNNS_ADM =  |w_TNNS_ADM =  |b_TNNS_ADM =  |g_TNNS_ADM = 
|m_TNNS_DLS =  |w_TNNS_DLS =  |b_TNNS_DLS =  |g_TNNS_DLS = 
|m_TNNS_FEU =  |w_TNNS_FEU =  |b_TNNS_FEU =  |g_TNNS_FEU = 
|m_TNNS_NUI =  |w_TNNS_NUI =  |b_TNNS_NUI =  |g_TNNS_NUI = 
|m_TNNS_UEA =  |w_TNNS_UEA =  |b_TNNS_UEA =  |g_TNNS_UEA = 
|m_TNNS_UPD =  |w_TNNS_UPD =  |b_TNNS_UPD =  |g_TNNS_UPD = 
|m_TNNS_UST =  |w_TNNS_UST =  |b_TNNS_UST =  |g_TNNS_UST = 

<!-- Table tennis (TBTNS) -->
|m_TBTN_ADU =  |w_TBTN_ADU =  |b_TBTN_ADU =  |g_TBTN_ADU = 
|m_TBTN_ADM =  |w_TBTN_ADM =  |b_TBTN_ADM =  |g_TBTN_ADM = 
|m_TBTN_DLS =  |w_TBTN_DLS =  |b_TBTN_DLS =  |g_TBTN_DLS = 
|m_TBTN_FEU =  |w_TBTN_FEU =  |b_TBTN_FEU =  |g_TBTN_FEU = 
|m_TBTN_NUI =  |w_TBTN_NUI =  |b_TBTN_NUI =  |g_TBTN_NUI = 
|m_TBTN_UEA =  |w_TBTN_UEA =  |b_TBTN_UEA =  |g_TBTN_UEA = 
|m_TBTN_UPD =  |w_TBTN_UPD =  |b_TBTN_UPD =  |g_TBTN_UPD = 
|m_TBTN_UST =  |w_TBTN_UST =  |b_TBTN_UST =  |g_TBTN_UST = 

<!-- Badminton (BDMT) -->
|m_BDMT_ADU =  |w_BDMT_ADU = 
|m_BDMT_ADM =  |w_BDMT_ADM = 
|m_BDMT_DLS =  |w_BDMT_DLS = 
|m_BDMT_FEU =  |w_BDMT_FEU = 
|m_BDMT_NUI =  |w_BDMT_NUI = 
|m_BDMT_UEA =  |w_BDMT_UEA = 
|m_BDMT_UPD =  |w_BDMT_UPD = 
|m_BDMT_UST =  |w_BDMT_UST = 

<!-- Taekwondo (M/W/B, TKWD)               // Poomsae (S, TKWD) -->
|m_TKWD_ADU =  |w_TKWD_ADU =  |b_TKWD_ADU =  |s_TKWD_ADU = 
|m_TKWD_ADM =  |w_TKWD_ADM =  |b_TKWD_ADM =  |s_TKWD_ADM = 
|m_TKWD_DLS =  |w_TKWD_DLS =  |b_TKWD_DLS =  |s_TKWD_DLS = 
|m_TKWD_FEU =  |w_TKWD_FEU =  |b_TKWD_FEU =  |s_TKWD_FEU = 
|m_TKWD_NUI =  |w_TKWD_NUI =  |b_TKWD_NUI =  |s_TKWD_NUI = 
|m_TKWD_UEA =  |w_TKWD_UEA =  |b_TKWD_UEA =  |s_TKWD_UEA = 
|m_TKWD_UPD =  |w_TKWD_UPD =  |b_TKWD_UPD =  |s_TKWD_UPD = 
|m_TKWD_UST =  |w_TKWD_UST =  |b_TKWD_UST =  |s_TKWD_UST = 

<!-- Judo (JUDO) -->
|m_JUDO_ADU =  |w_JUDO_ADU =  |b_JUDO_ADU =  |g_JUDO_ADU = 
|m_JUDO_ADM =  |w_JUDO_ADM =  |b_JUDO_ADM =  |g_JUDO_ADM = 
|m_JUDO_DLS =  |w_JUDO_DLS =  |b_JUDO_DLS =  |g_JUDO_DLS = 
|m_JUDO_FEU =  |w_JUDO_FEU =  |b_JUDO_FEU =  |g_JUDO_FEU = 
|m_JUDO_NUI =  |w_JUDO_NUI =  |b_JUDO_NUI =  |g_JUDO_NUI = 
|m_JUDO_UEA =  |w_JUDO_UEA =  |b_JUDO_UEA =  |g_JUDO_UEA = 
|m_JUDO_UPD =  |w_JUDO_UPD =  |b_JUDO_UPD =  |g_JUDO_UPD = 
|m_JUDO_UST =  |w_JUDO_UST =  |b_JUDO_UST =  |g_JUDO_UST = 

<!-- Baseball (M/B, BSBL)    // Softball (W/G, SFBL) -->
|m_BSBL_ADU =  |b_BSBL_ADU =  |w_SFBL_ADU =  |g_SFBL_ADU = 
|m_BSBL_ADM =  |b_BSBL_ADM =  |w_SFBL_ADM =  |g_SFBL_ADM = 
|m_BSBL_DLS =  |b_BSBL_DLS =  |w_SFBL_DLS =  |g_SFBL_DLS = 
|m_BSBL_FEU =  |b_BSBL_FEU =  |w_SFBL_FEU =  |g_SFBL_FEU = 
|m_BSBL_NUI =  |b_BSBL_NUI =  |w_SFBL_NUI =  |g_SFBL_NUI = 
|m_BSBL_UEA =  |b_BSBL_UEA =  |w_SFBL_UEA =  |g_SFBL_UEA = 
|m_BSBL_UPD =  |b_BSBL_UPD =  |w_SFBL_UPD =  |g_SFBL_UPD = 
|m_BSBL_UST =  |b_BSBL_UST =  |w_SFBL_UST =  |g_SFBL_UST = 

<!-- Football (FTBL) -->
|m_FTBL_ADU =  |w_FTBL_ADU =  |b_FTBL_ADU =  |g_FTBL_ADU = 
|m_FTBL_ADM =  |w_FTBL_ADM =  |b_FTBL_ADM =  |g_FTBL_ADM = 
|m_FTBL_DLS =  |w_FTBL_DLS =  |b_FTBL_DLS =  |g_FTBL_DLS = 
|m_FTBL_FEU =  |w_FTBL_FEU =  |b_FTBL_FEU =  |g_FTBL_FEU = 
|m_FTBL_NUI =  |w_FTBL_NUI =  |b_FTBL_NUI =  |g_FTBL_NUI = 
|m_FTBL_UEA =  |w_FTBL_UEA =  |b_FTBL_UEA =  |g_FTBL_UEA = 
|m_FTBL_UPD =  |w_FTBL_UPD =  |b_FTBL_UPD =  |g_FTBL_UPD = 
|m_FTBL_UST =  |w_FTBL_UST =  |b_FTBL_UST =  |g_FTBL_UST = 

<!-- Athletics or track & field (ATHL) -->
|m_ATHL_ADU =  |w_ATHL_ADU =  |b_ATHL_ADU =  |g_ATHL_ADU = 
|m_ATHL_ADM =  |w_ATHL_ADM =  |b_ATHL_ADM =  |g_ATHL_ADM = 
|m_ATHL_DLS =  |w_ATHL_DLS =  |b_ATHL_DLS =  |g_ATHL_DLS = 
|m_ATHL_FEU =  |w_ATHL_FEU =  |b_ATHL_FEU =  |g_ATHL_FEU = 
|m_ATHL_NUI =  |w_ATHL_NUI =  |b_ATHL_NUI =  |g_ATHL_NUI = 
|m_ATHL_UEA =  |w_ATHL_UEA =  |b_ATHL_UEA =  |g_ATHL_UEA = 
|m_ATHL_UPD =  |w_ATHL_UPD =  |b_ATHL_UPD =  |g_ATHL_UPD = 
|m_ATHL_UST =  |w_ATHL_UST =  |b_ATHL_UST =  |g_ATHL_UST = 

<!-- Fencing (FENC) -->
|m_FENC_ADU =  |w_FENC_ADU =  |b_FENC_ADU =  |g_FENC_ADU = 
|m_FENC_ADM =  |w_FENC_ADM =  |b_FENC_ADM =  |g_FENC_ADM = 
|m_FENC_DLS =  |w_FENC_DLS =  |b_FENC_DLS =  |g_FENC_DLS = 
|m_FENC_FEU =  |w_FENC_FEU =  |b_FENC_FEU =  |g_FENC_FEU = 
|m_FENC_NUI =  |w_FENC_NUI =  |b_FENC_NUI =  |g_FENC_NUI = 
|m_FENC_UEA =  |w_FENC_UEA =  |b_FENC_UEA =  |g_FENC_UEA = 
|m_FENC_UPD =  |w_FENC_UPD =  |b_FENC_UPD =  |g_FENC_UPD = 
|m_FENC_UST =  |w_FENC_UST =  |b_FENC_UST =  |g_FENC_UST = 
}}
National Collegiate Athletic Association (NCAA)
{{#invoke:PHL sports overall tally|main|final=n
|pts_1st=50|pts_2nd=40|pts_3rd=35|pts_4th=30|pts_5th=25
|pts_6th=20|pts_7th=15|pts_8th=10|pts_9th=8|pts_10th=6

|team1  = AUN
|team2  = CSB |j_short_CSB = LSGH
|team3  = CSJ
|team4  = EAC |j_short_EAC = ICA
|team5  = JRU
|team6  = LPU
|team7  = MUN |j_short_MUN = MHSS
|team8  = SBU |j_short_SBU = SBU-R
|team9  = SSC
|team10 = UPH

<!-- Basketball (BSKB) -->
|m_BSKB_AUN =  |b_BSKB_AUN = 
|m_BSKB_CSB =  |b_BSKB_CSB = 
|m_BSKB_CSJ =  |b_BSKB_CSJ = 
|m_BSKB_EAC =  |b_BSKB_EAC = 
|m_BSKB_JRU =  |b_BSKB_JRU = 
|m_BSKB_LPU =  |b_BSKB_LPU = 
|m_BSKB_MUN =  |b_BSKB_MUN = 
|m_BSKB_SBU =  |b_BSKB_SBU = 
|m_BSKB_SSC =  |b_BSKB_SSC = 
|m_BSKB_UPH =  |b_BSKB_UPH = 

<!-- 3x3 basketball (3X3B) -->
|m_3X3B_AUN =  |b_3X3B_AUN = 
|m_3X3B_CSB =  |b_3X3B_CSB = 
|m_3X3B_CSJ =  |b_3X3B_CSJ = 
|m_3X3B_EAC =  |b_3X3B_EAC = 
|m_3X3B_JRU =  |b_3X3B_JRU = 
|m_3X3B_LPU =  |b_3X3B_LPU = 
|m_3X3B_MUN =  |b_3X3B_MUN = 
|m_3X3B_SBU =  |b_3X3B_SBU = 
|m_3X3B_SSC =  |b_3X3B_SSC = 
|m_3X3B_UPH =  |b_3X3B_UPH = 

<!-- Indoor volleyball (INVB) -->
|m_INVB_AUN =  |w_INVB_AUN =  |b_INVB_AUN =  |g_INVB_AUN = 
|m_INVB_CSB =  |w_INVB_CSB =  |b_INVB_CSB =  |g_INVB_CSB = 
|m_INVB_CSJ =  |w_INVB_CSJ =  |b_INVB_CSJ =  |g_INVB_CSJ = 
|m_INVB_EAC =  |w_INVB_EAC =  |b_INVB_EAC =  |g_INVB_EAC = 
|m_INVB_JRU =  |w_INVB_JRU =  |b_INVB_JRU =  |g_INVB_JRU = 
|m_INVB_LPU =  |w_INVB_LPU =  |b_INVB_LPU =  |g_INVB_LPU = 
|m_INVB_MUN =  |w_INVB_MUN =  |b_INVB_MUN =  |g_INVB_MUN = 
|m_INVB_SBU =  |w_INVB_SBU =  |b_INVB_SBU =  |g_INVB_SBU = 
|m_INVB_SSC =  |w_INVB_SSC =  |b_INVB_SSC =  |g_INVB_SSC = 
|m_INVB_UPH =  |w_INVB_UPH =  |b_INVB_UPH =  |g_INVB_UPH = 

<!-- Beach volleyball (BCVB) -->
|m_BCVB_AUN =  |w_BCVB_AUN =  |b_BCVB_AUN = 
|m_BCVB_CSB =  |w_BCVB_CSB =  |b_BCVB_CSB = 
|m_BCVB_CSJ =  |w_BCVB_CSJ =  |b_BCVB_CSJ = 
|m_BCVB_EAC =  |w_BCVB_EAC =  |b_BCVB_EAC = 
|m_BCVB_JRU =  |w_BCVB_JRU =  |b_BCVB_JRU = 
|m_BCVB_LPU =  |w_BCVB_LPU =  |b_BCVB_LPU = 
|m_BCVB_MUN =  |w_BCVB_MUN =  |b_BCVB_MUN = 
|m_BCVB_SBU =  |w_BCVB_SBU =  |b_BCVB_SBU = 
|m_BCVB_SSC =  |w_BCVB_SSC =  |b_BCVB_SSC = 
|m_BCVB_UPH =  |w_BCVB_UPH =  |b_BCVB_UPH = 

<!-- Swimming (SWMM) -->
|m_SWMM_AUN =  |w_SWMM_AUN =  |b_SWMM_AUN = 
|m_SWMM_CSB =  |w_SWMM_CSB =  |b_SWMM_CSB = 
|m_SWMM_CSJ =  |w_SWMM_CSJ =  |b_SWMM_CSJ = 
|m_SWMM_EAC =  |w_SWMM_EAC =  |b_SWMM_EAC = 
|m_SWMM_JRU =  |w_SWMM_JRU =  |b_SWMM_JRU = 
|m_SWMM_LPU =  |w_SWMM_LPU =  |b_SWMM_LPU = 
|m_SWMM_MUN =  |w_SWMM_MUN =  |b_SWMM_MUN = 
|m_SWMM_SBU =  |w_SWMM_SBU =  |b_SWMM_SBU = 
|m_SWMM_SSC =  |w_SWMM_SSC =  |b_SWMM_SSC = 
|m_SWMM_UPH =  |w_SWMM_UPH =  |b_SWMM_UPH = 

<!-- Chess (CHSS) -->
|m_CHSS_AUN =  |b_CHSS_AUN = 
|m_CHSS_CSB =  |b_CHSS_CSB = 
|m_CHSS_CSJ =  |b_CHSS_CSJ = 
|m_CHSS_EAC =  |b_CHSS_EAC = 
|m_CHSS_JRU =  |b_CHSS_JRU = 
|m_CHSS_LPU =  |b_CHSS_LPU = 
|m_CHSS_MUN =  |b_CHSS_MUN = 
|m_CHSS_SBU =  |b_CHSS_SBU = 
|m_CHSS_SSC =  |b_CHSS_SSC = 
|m_CHSS_UPH =  |b_CHSS_UPH = 

<!-- Tennis (M/B, TNNS) and Soft tennis (W, SFTN) -->
|m_TNNS_AUN =  |w_SFTN_AUN =  |b_TNNS_AUN = 
|m_TNNS_CSB =  |w_SFTN_CSB =  |b_TNNS_CSB = 
|m_TNNS_CSJ =  |w_SFTN_CSJ =  |b_TNNS_CSJ = 
|m_TNNS_EAC =  |w_SFTN_EAC =  |b_TNNS_EAC = 
|m_TNNS_JRU =  |w_SFTN_JRU =  |b_TNNS_JRU = 
|m_TNNS_LPU =  |w_SFTN_LPU =  |b_TNNS_LPU = 
|m_TNNS_MUN =  |w_SFTN_MUN =  |b_TNNS_MUN = 
|m_TNNS_SBU =  |w_SFTN_SBU =  |b_TNNS_SBU = 
|m_TNNS_SSC =  |w_SFTN_SSC =  |b_TNNS_SSC = 
|m_TNNS_UPH =  |w_SFTN_UPH =  |b_TNNS_UPH = 

<!-- Table tennis (TBTN) -->
|m_TBTN_AUN =  |w_TBTN_AUN =  |b_TBTN_AUN = 
|m_TBTN_CSB =  |w_TBTN_CSB =  |b_TBTN_CSB = 
|m_TBTN_CSJ =  |w_TBTN_CSJ =  |b_TBTN_CSJ = 
|m_TBTN_EAC =  |w_TBTN_EAC =  |b_TBTN_EAC = 
|m_TBTN_JRU =  |w_TBTN_JRU =  |b_TBTN_JRU = 
|m_TBTN_LPU =  |w_TBTN_LPU =  |b_TBTN_LPU = 
|m_TBTN_MUN =  |w_TBTN_MUN =  |b_TBTN_MUN = 
|m_TBTN_SBU =  |w_TBTN_SBU =  |b_TBTN_SBU = 
|m_TBTN_SSC =  |w_TBTN_SSC =  |b_TBTN_SSC = 
|m_TBTN_UPH =  |w_TBTN_UPH =  |b_TBTN_UPH = 

<!-- Badminton (BDMT) -->
|m_BDMT_AUN =  |w_BDMT_AUN =  |b_BDMT_AUN = 
|m_BDMT_CSB =  |w_BDMT_CSB =  |b_BDMT_CSB = 
|m_BDMT_CSJ =  |w_BDMT_CSJ =  |b_BDMT_CSJ = 
|m_BDMT_EAC =  |w_BDMT_EAC =  |b_BDMT_EAC = 
|m_BDMT_JRU =  |w_BDMT_JRU =  |b_BDMT_JRU = 
|m_BDMT_LPU =  |w_BDMT_LPU =  |b_BDMT_LPU = 
|m_BDMT_MUN =  |w_BDMT_MUN =  |b_BDMT_MUN = 
|m_BDMT_SBU =  |w_BDMT_SBU =  |b_BDMT_SBU = 
|m_BDMT_SSC =  |w_BDMT_SSC =  |b_BDMT_SSC = 
|m_BDMT_UPH =  |w_BDMT_UPH =  |b_BDMT_UPH = 

<!-- Taekwondo (TKWD) -->
|m_TKWD_AUN =  |w_TKWD_AUN =  |b_TKWD_AUN = 
|m_TKWD_CSB =  |w_TKWD_CSB =  |b_TKWD_CSB = 
|m_TKWD_CSJ =  |w_TKWD_CSJ =  |b_TKWD_CSJ = 
|m_TKWD_EAC =  |w_TKWD_EAC =  |b_TKWD_EAC = 
|m_TKWD_JRU =  |w_TKWD_JRU =  |b_TKWD_JRU = 
|m_TKWD_LPU =  |w_TKWD_LPU =  |b_TKWD_LPU = 
|m_TKWD_MUN =  |w_TKWD_MUN =  |b_TKWD_MUN = 
|m_TKWD_SBU =  |w_TKWD_SBU =  |b_TKWD_SBU = 
|m_TKWD_SSC =  |w_TKWD_SSC =  |b_TKWD_SSC = 
|m_TKWD_UPH =  |w_TKWD_UPH =  |b_TKWD_UPH = 

<!-- Judo (JUDO) -->
|m_JUDO_AUN =  |w_JUDO_AUN =  |b_JUDO_AUN = 
|m_JUDO_CSB =  |w_JUDO_CSB =  |b_JUDO_CSB = 
|m_JUDO_CSJ =  |w_JUDO_CSJ =  |b_JUDO_CSJ = 
|m_JUDO_EAC =  |w_JUDO_EAC =  |b_JUDO_EAC = 
|m_JUDO_JRU =  |w_JUDO_JRU =  |b_JUDO_JRU = 
|m_JUDO_LPU =  |w_JUDO_LPU =  |b_JUDO_LPU = 
|m_JUDO_MUN =  |w_JUDO_MUN =  |b_JUDO_MUN = 
|m_JUDO_SBU =  |w_JUDO_SBU =  |b_JUDO_SBU = 
|m_JUDO_SSC =  |w_JUDO_SSC =  |b_JUDO_SSC = 
|m_JUDO_UPH =  |w_JUDO_UPH =  |b_JUDO_UPH = 

<!-- Football (FTBL) -->
|m_FTBL_AUN =  |b_FTBL_AUN = 
|m_FTBL_CSB =  |b_FTBL_CSB = 
|m_FTBL_CSJ =  |b_FTBL_CSJ = 
|m_FTBL_EAC =  |b_FTBL_EAC = 
|m_FTBL_JRU =  |b_FTBL_JRU = 
|m_FTBL_LPU =  |b_FTBL_LPU = 
|m_FTBL_MUN =  |b_FTBL_MUN = 
|m_FTBL_SBU =  |b_FTBL_SBU = 
|m_FTBL_SSC =  |b_FTBL_SSC = 
|m_FTBL_UPH =  |b_FTBL_UPH = 

<!-- Athletics / track and field (ATHL) -->
|m_ATHL_AUN =  |b_ATHL_AUN = 
|m_ATHL_CSB =  |b_ATHL_CSB = 
|m_ATHL_CSJ =  |b_ATHL_CSJ = 
|m_ATHL_EAC =  |b_ATHL_EAC = 
|m_ATHL_JRU =  |b_ATHL_JRU = 
|m_ATHL_LPU =  |b_ATHL_LPU = 
|m_ATHL_MUN =  |b_ATHL_MUN = 
|m_ATHL_SBU =  |b_ATHL_SBU = 
|m_ATHL_SSC =  |b_ATHL_SSC = 
|m_ATHL_UPH =  |b_ATHL_UPH = 
}}

Usage

In it's simplest form, only several parameters need to be used to build a table.

League What you type What it looks like
UAAP
{{#invoke:PHL sports overall tally|main|final=n

|team1 = ADU
|team2 = ADM
|team3 = DLS
|team4 = FEU
|team5 = NUI
|team6 = UEA
|team7 = UPD
|team8 = UST
}}
Lua error: expandTemplate: template "UAAPteam" does not exist.
NCAA
{{#invoke:PHL sports overall tally|main|final=n
|pts_1st=50|pts_2nd=40|pts_3rd=35|pts_4th=30|pts_5th=25
|pts_6th=20|pts_7th=15|pts_8th=10|pts_9th=8 |pts_10th=6

|team01 = AUN
|team02 = CSB
|team03 = EAC
|team04 = JRU
|team05 = CSJ
|team06 = LPU
|team07 = MUN
|team08 = SBU
|team09 = SSC
|team10 = UPH
}}
Lua error: expandTemplate: template "UAAPteam" does not exist.

Parameters

General parameters
Parameter Description
teamN The name or code of team N, e.g. |team1=ABC. Parameter key must contain a three-letter code. Number N do not reflect rankings on the table unless |overall_pts_only=y.
status_ABC The status of team ABC. Supported values include H (season host).
division The tournament division. Supported values include senior (default) and junior.
source A citation or actual link to the source.
final Indicator if results are final. Set to n if season is in-progress. Omit or set to y if results are final.
show_medals Toggle to display medals table as implemented in {{Medals table}}. Set to y to enable this display style.
subtotals_only Toggle to display table with points per division (subtotals) and the overall total points. Set to y to enable this display style.
overall_pts_only Toggle to display table only with the overall points. Set to y to enable this display style.
Championship point parameters
Parameter Description
m_BSKB_ABC The (numeric) rank of team ABC in an event or sport.

If champions, then |m_BSKB_ABC=1; else if second placer, then |m_BSKB_ABC=2; else if fifth placer, then |m_BSKB_ABC=5 and so on.

In case of a tie, prepend letter T to the numeric rank, e.g. |m_BSKB_ABC=T2 if tied for second place, or |m_BSKB_ABC=T4 for fourth place.

Parameter syntax must be followed: Division_EventCode_TeamCode

  • m – The division code. Supported values include:
    • for seniors': m (men's), w (women's), and s (mixed or co-ed); and
    • for juniors': b (boys'), g (girls'), and j (mixed or co-ed)
  • BSKB – The event code. See the events section below for list of supported tournaments and their corresponding event codes.
  • ABC – The team's three-letter code
pts_1st The number of points given to the champions or 1st placer. The default is 15.

Override points for other rankings:

  • pts_2nd - The number of points given to the runners-up or second placer. The default is 12.
  • pts_3rd - The number of points given to the third placer. The default is 10.
  • pts_nth - The number of points given to the last placer, where n is the total number of teams provided by parameters teamN. All points N provided which exceed the total number of teams will be ignored.
pts_ABC The overall points obtained by team ABC. Parameter will take effect only if |overall_pts_only=y.

Events

The following are the tournaments supported by this module:

Event code Event
BSKB Basketball
3X3B 3x3 basketball
INVB Indoor volleyball
BCVB Beach volleyball
SWMM Swimming
CHSS Chess
TNNS Tennis
SFTN Soft tennis
TBTN Table tennis
BDMT Badminton
TKWD Taekwondo
JUDO Judo
BSBL Baseball
SFBL Softball
FTBL Football
ATHL Athletics / track and field
FENC Fencing
ESPT Electronic sports

Examples

Example 1: Overview style

Example 1A: Table only with overall total points

  • If point value of a team is blank, not provided or a string, value will be displayed as 0, e.g. the cases of pts_BBB (missing) and pts_DDD (a string) below.
What you type What it looks like
{{#invoke:PHL sports overall tally|main|overall_pts_only=y
|source=My source here

|team1 = AAA  |name_AAA = {{UAAPteam|UST}} |pts_AAA = 444
|team2 = BBB  |name_BBB = [[Dream Team]]
|team3 = CCC  |name_CCC = Team C           |pts_CCC  = 345
|team4 = DDD  |name_DDD = Team D           |pts_DDD  = Dunno
|team5 = EEE  |name_EEE = {{bk|ESP}}       |pts_EEE  = 400
|team6 = FFFF |name_FFFF = {{bk|AUS}}      |pts_FFFF = 350 |status_FFFF = H
|team7 = GG   |name_GG   = {{bk|ARG}}      |pts_GG   = 390
}}
RankTeamPoints
1Template:UAAPteam444
2 Spain400
3 Argentina390
4 Australia (H)350
5Team C345
6Dream Team0
Team D
Source: My source here
(H) Season host.
Notes: Results are final.

Example 1B: Medals table

  • Medals data table will automatically reflect given the rankings on each event; i.e. numbers 1, 2, and 3 corresponds to gold, silver and bronze medals, respectively.
What you type What it looks like
{{#invoke:PHL sports overall tally|main|show_medals=y
|team1 = UST
|team2 = BBB |name_BBB = [[Dream Team]]
|team3 = CCC |name_CCC = Team C
|team4 = DDD |name_DDD = Team D
|team5 = EEE |name_EEE = {{bk|ESP}} |status_EEE = H

|m_3X3B_UST= 1 |w_3X3B_UST= 3 |m_FENC_UST = 4 |s_TKWD_UST= 2 |w_JUDO_UST= 1
|m_3X3B_BBB= 4 |w_3X3B_BBB= 1 |m_FENC_BBB = 5 |s_TKWD_BBB= 3 |w_JUDO_BBB= 4
|m_3X3B_CCC= 2 |w_3X3B_CCC= 5 |m_FENC_CCC = 3 |s_TKWD_CCC= 5 |w_JUDO_CCC= 5
|m_3X3B_DDD= 5 |w_3X3B_DDD= 2 |m_FENC_DDD = 1 |s_TKWD_DDD= 4 |w_JUDO_DDD= 2
|m_3X3B_EEE= 3 |w_3X3B_EEE= 4 |m_FENC_EEE = 2 |s_TKWD_EEE= 1 |w_JUDO_EEE= 3
}}
Lua error: expandTemplate: template "UAAPteam" does not exist.

Example 2: Detailed tally table

Example 2A: Using default values

  • An event column will not appear if first-placer for that tournament is not found, e.g. the case of w_JUDO parameters below
  • If point value is blank or 0, it is assumed the team did not participate the tournament, e.g. the cases of w_3X3B_CCC and w_3X3B_EEE below
What you type What it looks like
{{#invoke:PHL sports overall tally|main
|final=n|source=My source here

|team1 = UST
|team2 = BBB |name_BBB = [[Dream Team]]
|team3 = CCC |name_CCC = Team C
|team4 = DDD |name_DDD = Team D
|team5 = EEE |name_EEE = {{bk|ESP}}

|m_3X3B_UST= 1 |w_3X3B_UST= 3 |m_FENC_UST = 4 |s_TKWD_UST= 2 |w_JUDO_UST= 0
|m_3X3B_BBB= 4 |w_3X3B_BBB= 1 |m_FENC_BBB = 5 |s_TKWD_BBB= 3 |w_JUDO_BBB= 6
|m_3X3B_CCC=   |w_3X3B_CCC= 5 |m_FENC_CCC = 3 |s_TKWD_CCC= 5 |w_JUDO_CCC= 8
|m_3X3B_DDD= 5 |w_3X3B_DDD= 2 |m_FENC_DDD = 1 |s_TKWD_DDD= 4 |w_JUDO_DDD= 2
|m_3X3B_EEE= 3 |w_3X3B_EEE= 0 |m_FENC_EEE = 2 |s_TKWD_EEE= 1 |w_JUDO_EEE= 0
}}
Lua error: expandTemplate: template "UAAPteam" does not exist.

Example 2B: Overriding the default 1st/2nd/3rd placer points

  • Unsupported events will not appear, e.g. the case of c_XXXX parameters below
  • If rank is greater than total number of teams, it is assumed the team did not participate the tournament, e.g. the case of w_JUDO_JJJ below (Rank 9 out of 5 teams)
What you type What it looks like
{{#invoke:PHL sports overall tally|main
|pts_1st=50|pts_2nd=40

|team1 = CSJ
|team2 = GGG |name_GGG = {{bk|NZL}} |status_GGG = H
|team3 = HHH |name_HHH = Team H
|team4 = III |name_III = [[School of Hard Knocks]]
|team5 = JJJ |name_JJJ = Team J

|m_JUDO_CSJ= 1 |w_JUDO_CSJ= 3 |m_ATHL_CSJ = 5 |s_XXXX_CSJ= 4
|m_JUDO_GGG= 2 |w_JUDO_GGG= 1 |m_ATHL_GGG = 0 |s_XXXX_GGG= 3
|m_JUDO_HHH= 3 |w_JUDO_HHH= 2 |m_ATHL_HHH = 3 |s_XXXX_HHH= 1
|m_JUDO_III= 4 |w_JUDO_III= 3 |m_ATHL_III = 2 |s_XXXX_III= 2
|m_JUDO_JJJ= 5 |w_JUDO_JJJ= 9 |m_ATHL_JJJ = 1 |s_XXXX_JJJ= 0
}}
Lua error: expandTemplate: template "UAAPteam" does not exist.

Example 2C: Juniors' division

  • Unnecessary parameters will be ignored, e.g. the case of m_FENC and w_FENC parameters below (as both m and w are considered collegiate division)
What you type What it looks like
{{#invoke:PHL sports overall tally|main|division=junior
|team1 = UST
|team2 = BBB |name_BBB = [[Dream Team]]
|team3 = CCC |name_CCC = Team C
|team4 = DDD |name_DDD = Team D
|team5 = EEE |name_EEE = {{bk|ESP}} |status_EEE = H

|b_FENC_UST= 1 |g_FENC_UST= 3 |w_FENC_UST = 4 |j_ATHL_UST= 2 |g_CHSS_UST= 3
|b_FENC_BBB= 4 |g_FENC_BBB= 1 |w_FENC_BBB = 5 |j_ATHL_BBB= 4 |g_CHSS_BBB= 5
|b_FENC_CCC= 2 |g_FENC_CCC=   |m_FENC_CCC = 3 |j_ATHL_CCC= 5 |g_CHSS_CCC= 4
|b_FENC_DDD= 5 |g_FENC_DDD= 2 |m_FENC_DDD = 1 |j_ATHL_DDD= 3 |g_CHSS_DDD= 2
|b_FENC_EEE= 3 |g_FENC_EEE= 0 |m_FENC_EEE = 2 |j_ATHL_EEE= 1 |g_CHSS_EEE= 1
}}
Lua error: expandTemplate: template "UAAPteam" does not exist.

Example 2D: Tie in rankings

  • In example below, teams are ranked as follows:
    • |m_3X3B_BBB=T4 and |m_3X3B_CCC=T4T4 denotes tie at fourth place, getting 7 points each
    • |m_FENC_UST=T2, |m_FENC_BBB=T2 and |m_FENC_EEE=T2T2 denotes three-way tie at second place, getting 10 points each
{{#invoke:PHL sports overall tally|main|final=n

|team1 = UST
|team2 = BBB |name_BBB = [[Dream Team]]
|team3 = CCC |name_CCC = Team C
|team4 = DDD |name_DDD = Team D
|team5 = EEE |name_EEE = {{bk|ESP}} |status_EEE = H

|m_3X3B_UST=  1 |w_3X3B_UST= 3 |m_FENC_UST = T2 |s_TKWD_UST= 2
|m_3X3B_BBB= T4 |w_3X3B_BBB= 1 |m_FENC_BBB = T2 |s_TKWD_BBB= 5
|m_3X3B_CCC= T4 |w_3X3B_CCC= 5 |m_FENC_CCC =  5 |s_TKWD_CCC= 3
|m_3X3B_DDD=  3 |w_3X3B_DDD= 2 |m_FENC_DDD =  1 |s_TKWD_DDD= 4
|m_3X3B_EEE=  2 |w_3X3B_EEE= 0 |m_FENC_EEE = T2 |s_TKWD_EEE= 1
}}
Lua error: expandTemplate: template "UAAPteam" does not exist.

require('Module:No globals')

local p = {
	TIE_REGEX = '^T([%d]+)%s*$'
}

local div = {
	senior = { 'M', 'W', 'C'},
	junior = { 'B', 'G', 'C'}
}

local evt = { 
	{'BSKB', 'Basketball' },
	{'3X3B', '3x3 basketball' },
	{'INVB', 'Volleyball (indoor)' },
	{'BCVB', 'Volleyball (beach)' },
	{'SWMM', 'Swimming' },
	{'CHSS', 'Chess' },
	{'TNNS', 'Tennis' },
	{'SFTN', 'Soft tennis' },
	{'TBTN', 'Table tennis' },
	{'BDMT', 'Badminton' },
	{'TKWD', 'Taekwondo' },
	{'JUDO', 'Judo' },
	{'BSBL', 'Baseball' },
	{'SFBL', 'Softball' },
	{'FTBL', 'Football' },
	{'ATHL', 'Athletics' },
	{'FENC', 'Fencing' },
	{'ESPT', 'Electronic sports' }
}

local colors = {
			 { 'gold',	  'Champion'},
			 { 'silver',  'Runner-up' },
			 { '#CC9966', 'Third place' },
	['WD'] = { '#FFBBBB', 'Withdrew' },
	['NT'] = { nil, 	  'No team' }
}

local function isnotempty(s)
	return s and s:match('^%s*(.-)%s*$') ~= ''
end

local function stripwhitespace(text)
	return text:match("^%s*(.-)%s*$")
end

local function findchamp(teams, t, r)
	local found = (teams[t].res[r].rank == 1 or teams[t].res[r].raw == 'T1')
	if found or (t == 1) then return found else return findchamp(teams, t - 1, r) end
end

local function countties(teams, r)
	local tie = {}
	for kt, vt in pairs(teams) do
		local raw = vt.res[r].raw or ''
		if (raw):match(p.TIE_REGEX) then
			tie[raw] = (tie[raw] or 0) + 1
		end
	end
	return tie
end

local function getevtdisp(teams, division)
	local r = 1
	local evt_disp = {}
	for ke, ve in pairs(evt) do
		for kd, vd in pairs(div[division]) do
			local showevt = findchamp(teams, #teams, r)
			local ties = countties(teams, r)
			table.insert(evt_disp, { show = showevt, ties = ties })
			r = r + 1
		end
	end
	return evt_disp
end

local function getevtindex(value)
	for k, v in pairs(evt) do
		if v[1] == value then return tonumber(k) end
	end
	return tonumber(99)
end

local function getvte(frame, args)
	local baselink = frame:getParent():getTitle()
	if mw.title.getCurrentTitle().text == baselink then	baselink = '' end
	local vtetemplate = args['tname'] or (baselink ~= '' and (':' .. baselink)) or ''

	if vtetemplate ~= '' then
		return frame:expandTemplate{ title = 'navbar', args = { mini=1, style='float:left', brackets=1, vtetemplate} }
	end
	return nil
end

local function getbg(rank, raw)
	rank = tonumber(tostring(raw):match(p.TIE_REGEX) or rank) or 0
	if rank > 0 and rank <= 3 then return colors[rank][1]
	elseif raw == 'WD' then return colors.WD[1]
	else return nil
	end
end

local function comptiepts(ptsbyrank, trank, teamsize, ctie)
	local count = ctie['T'..trank]
	if count == 0 then return ptsbyrank[trank] end
	local limit, total = trank + count - 1, 0
	if limit > teamsize then error('Invalid number of teams tied on #'..trank) end
	for i=trank, limit do
		total = ptsbyrank[i] + total
	end
	return total / count
end

local function getpts(rank, raw, ptsbyrank, tsize, ctie)
	local  trank = tonumber(tostring(raw):match(p.TIE_REGEX)) or 0
	if	   trank > 0 then return comptiepts(ptsbyrank,trank,tsize,ctie) or ptsbyrank.NT
	elseif string.match(raw,'([?|WD])') then return raw
	else   return ptsbyrank[rank] or ptsbyrank.NT
	end
end

local function prefillvalues(args,teams,division,ptsbyrank,ovptsonly)
	local tally = {}
	for kt, vt in pairs(teams) do
		local res, subtotal, overall, gold, silver, bronze = {}, {}, 0, 0, 0, 0
		
		local evt_disp = getevtdisp(teams,division,ptsbyrank)
		for kr, vr in pairs(vt.res) do
			local evtprop = evt_disp[kr]
			if evtprop.show then
				local rank = tonumber(tostring(vr.raw):match(p.TIE_REGEX)) or vr.rank
					vr.pts = tonumber(getpts(rank,vr.raw,ptsbyrank,#teams,evtprop.ties)) or 0
				subtotal[vr.div] = (tonumber(subtotal[vr.div]) or 0) + vr.pts
				if	   rank == 1 then gold = gold + 1
				elseif rank == 2 then silver = silver + 1
				elseif rank == 3 then bronze = bronze + 1 end
				table.insert(res, vr)
			end
		end
		for kd, vd in pairs(div[division]) do overall = overall + tonumber(subtotal[vd] or 0) end

		if ovptsonly then
			overall = tonumber(args['pts_'..vt.code]) or overall
		end
		table.insert(tally, { rank = vt.rank, code = vt.code, team = vt.name, res = res, subtotal = subtotal, overall = overall, medals = { gold, silver, bronze } })
	end
	table.sort(tally, function (a, b) return a.overall > b.overall or (a.overall == b.overall and a.rank < b.rank) end)
	return tally
end

local function medaltable(frame,args,tally,division,isfinal)
	local mMedals = require('Module:Medals table')
	local legendL = 'Leads the '..(args['overall'] or 'general')..' championship tally'
	args['team'] = 'Team'
	args['event'] = 'inst'
	args['legend_position'] = 'b'
	args['flag_template'] = args['team_template'] or 'UAAPteam'
	args['host_note'] = string.format(';&nbsp;%s&nbsp;%s', frame:expandTemplate{title = 'color box', args = {'#E9D66B'}}, legendL)
	args['notes'] = isfinal and 'Results are final.' or 'Season in progress. Results are not yet final.'
	
	for kt, vt in pairs(tally) do
		local name = args['name_'..vt.code]
		if kt == 1 and vt.overall ~= 0 then
			args['leading_'..vt.code] = 'yes'
		end
		if division == 'junior' and isnotempty(args['j_short_'..vt.code]) then
			args['name_'..vt.code] = frame:expandTemplate{title = args['flag_template'], args = { vt.code, division, inst = args['j_short_'..vt.code] } }
		elseif division == 'senior' and isnotempty(args['short_'..vt.code]) then
			args['name_'..vt.code] = frame:expandTemplate{title = args['flag_template'], args = { vt.code, division, inst = args['short_'..vt.code] } }
		elseif not isnotempty(name) or name == nil then
			args['name_'..vt.code] = vt.name
		end
		if stripwhitespace(args['status_'..vt.code] or '') == 'H' then
			args['host_'..vt.code] = 'yes'
			args['host'] = 'Season host'
		end
		args['gold_'..vt.code] = vt.medals[1]
		args['silver_'..vt.code] = vt.medals[2]
		args['bronze_'..vt.code] = vt.medals[3]
	end
	return mMedals.createTable(frame, args)
end

local function buildtable(frame,args,teams,division,ptsbyrank,showmedals,ovptsonly,sumsonly,isfinal)
	local tally = prefillvalues(args,teams,division,ptsbyrank,ovptsonly)
	
	if showmedals then
		return medaltable(frame,args,tally,division,isfinal)
	end
	
	local root = mw.html.create()
	local footer = mw.html.create()
	local abbr = mw.html.create('abbr')
	root = root:tag('table')
		:addClass('wikitable')
		:addClass('plainrowheaders')
		:css('font-size', (ovptsonly or sumsonly) and '100%' or '95%')
		:css('text-align', 'center')
	
	-- header row (1)
	local evts = tally[1].res
	local divs = div[division]
	local row = root:tag('tr')
	local celltype = not ovptsonly and 'th' or 'td'
	local showwg, showc, showhost, hidedivs = false, false, false, true
	
	if not ovptsonly then
		row:tag('th')
			:attr('scope', 'col')
			:attr('colspan', '2')
			:wikitext(getvte(frame,args))
		
		abbr:attr('title', 'Mixed or co-ed'):wikitext(divs[3])
		
		-- column spanning by event
		local prevspan, prevcell, prevevt = 0, nil, nil
		for ke, ve in pairs(evts) do
			local evtname = evt[getevtindex(ve.evt)][2]
			if	   ve.div == divs[2] then showwg = true
			elseif ve.div == divs[3] then showc  = true end
			if not sumsonly then
				if (prevevt == ve.evt) then
					prevspan = prevspan + 1
					prevcell
						:attr('colspan', prevspan)
				else
					prevspan = 1
					prevcell = row:tag('th')
						:attr('scope', 'col')
						:wikitext(string.format('[[File:%s pictogram.svg|20px|link=|%s]]', evtname, evtname))
					prevevt = ve.evt
				end
			end
		end
		
		hidedivs = not showwg and not showc
		row:tag('th')
			:attr('scope', 'col')
			:attr('colspan', hidedivs and 1 or (((not showwg and showc) or (showwg and not showc)) and 3 or 4))
			:css('border-left-width', '3px')
			:wikitext('Total')
	end
	
	-- header row (2)
	row = root:tag('tr')
	row:tag('th')
			:attr('scope', 'col')
			:attr('width', '50px')
			:wikitext('Rank')
		:tag('th')
			:attr('scope', 'col')
			:attr('width', '90px')
			:wikitext('Team')
	
	if not (ovptsonly or sumsonly) then
		for ke, ve in pairs(evts) do
			row:tag('th')
				:attr('scope', 'col')
				:attr('width', '22px')
				:wikitext(ve.div == divs[3] and tostring(abbr) or ve.div)
		end
	end
	
	if not ovptsonly then
		for kd, vd in pairs(divs) do
			if  (hidedivs or
				(not showwg and vd == divs[2]) or
				(not showc and vd == divs[3])) then break
			else
				row:tag('th')
					:attr('scope', 'col')
					:attr('width', '22px')
					:css('border-left-width', (kd == 1) and '3px' or nil)
					:wikitext(vd == divs[3] and tostring(abbr) or vd)
			end
		end
	end
	
	row:tag('th')
		:attr('scope', 'col')
		:css('border-left-width', hidedivs and '3px' or nil)
		:wikitext(ovptsonly and 'Points' or 'Overall')
	
	-- row spanning by points
	local prevpts, prevspan, prevrankcell, prevtotalcell = -1, 0, nil, nil
	
	-- team row
	for ka, va in pairs(tally) do
		local teamtext = va.team

		if stripwhitespace(args['status_'..va.code] or '') == 'H' then
			showhost = true
			teamtext = va.team..'&nbsp;<b>(H)</b>'
		end
		
		row = root:tag('tr')
		
		if (prevpts == va.overall) then
			prevspan = prevspan + 1
			prevrankcell
				:attr('rowspan', prevspan)
		else
			prevspan = 1
			prevrankcell = row:tag(celltype)
					:attr('scope', 'row')
					:css('text-align', 'center')
					:wikitext(ka)
		end
		
		row:tag('td')
			:attr('scope', 'row')
			:css('white-space', 'nowrap')
			:css('text-align', 'left')
			:wikitext(teamtext)
					
		if not ovptsonly then
			if not sumsonly then
				for kr, vr in pairs(va.res) do
					row:tag('td')
						:css('background-color', getbg(vr.rank,vr.raw))
						:wikitext(vr.pts ~= 0 and vr.pts or ptsbyrank.NT)
				end
			end
			
			for kd, vd in pairs(divs) do
				if (hidedivs or
					(not showwg and vd == divs[2]) or
					(not showc and vd == divs[3])) then break
				else row:tag('td')
					:css('border-left-width', (kd == 1) and '3px' or nil)
					:wikitext(va.subtotal[vd] or 0)
				end
			end
		end
		
		if (prevpts == va.overall) then
			prevtotalcell
				:attr('rowspan', prevspan)
		else
			prevspan = 1
			prevtotalcell = row:tag(celltype)
				:attr('scope', 'row')
				:css('font-weight', 'bold')
				:css('text-align', 'center')
				:css('border-left-width', hidedivs and '3px' or nil)
				:wikitext(va.overall)
			prevpts = va.overall
		end
	end
	
	local source, legend = args['source'], footer:tag('div'):attr('class', 'reflist')
	
	if source then
		legend:tag(''):wikitext('Source: '.. source ..'<br>')
	end
	if showhost then
		legend:tag('span')
			:css('font-weight', 'bold')
			:wikitext('(H)')
			:done()
		:wikitext('&nbsp;Season host')
		if ovptsonly or sumsonly then legend:wikitext('.') end
	end
	if not (ovptsonly or sumsonly) then
		local firsttag = not showhost
		for kp, vp in pairs(ptsbyrank) do
			if not string.match(kp,p.TIE_REGEX) and (tonumber(kp) or 0) < 4 then
				if firsttag == false then legend:wikitext('; ') end
				legend:tag('span')
					:css('margin', '0')
					:css('white-space', 'nowrap')
					:tag('span')
						:addClass('legend-text')
						:css('border', 'none')
						:css('padding', '1px .3em')
						:css('background-color', getbg(kp))
						:css('font-size', '95%')
						:css('border', '1px solid #BBB')
						:css('line-height', '1.25')
						:css('text-align', 'center')
						:wikitext(type(vp) == 'number' and '&nbsp;' or vp)
						:done()
					:wikitext(' = ' .. (colors[kp] or colors.NT)[2])
				firsttag = false
			end
		end
		legend:wikitext('.')
	end
	
	legend:wikitext('<br>Notes: ' .. (isfinal and 'Results are final.' or 'Season in progress. Results are not yet final.'))

	return tostring(root)..tostring(footer)
end

function p.main(frame)
	local getArgs = require('Module:Arguments').getArgs
	local args = getArgs(frame, { parentFirst = true })
	
	local yesno = require('Module:Yesno')
	local showmedals = yesno(args['show_medals'] or 'n')
	local ovptsonly = yesno(args['overall_pts_only'] or 'n')
	local sumsonly = yesno(args['subtotals_only'] or 'n')
	local isfinal = yesno(args['final'] or 'y')
	local division = (args['division'] or 'senior'):lower()
	local template = args['team_template'] or 'UAAPteam'
	local team_list, defaultpts = {}, { 15, 12, 10, 8, 6, 4, 2, 1, NT = '&mdash;' }
	local ptsbyrank = { NT = defaultpts.NT }
	
	for ka, va in pairs(args) do
		-- Process team args
		local i = tostring(ka):match('^team([%d]+)%s*$') or '0'
		if (tonumber(i) > 0 and isnotempty(va)) then
			local res, t = {}, args['team' .. i]
			local sname = args['short_' .. t]
			if division == 'junior' and isnotempty(args['j_short_' .. t]) then sname = args['j_short_' .. t] end
			local tname = args['name_' .. t] or
				(isnotempty(sname) and
					frame:expandTemplate{title = template, args = { t, division, name = sname } } or 
					frame:expandTemplate{title = template, args = { t, division, 'short' } }
				)
			for ke, ve in pairs(evt) do
				for kd, vd in pairs(div[division]) do
					local cvd = vd
					if (kd == 3) then cvd = division:sub(1,1) end
					local evt_rank = stripwhitespace(args[cvd:lower()..'_'..ve[1]..'_'..t] or '')
					table.insert(res, { div = vd, evt = ve[1], raw = stripwhitespace(evt_rank), rank = tonumber(evt_rank) or 0 })
				end
			end
			table.insert(team_list, {rank = i, code = t, name = tname, res = res})
		end
	end
	
	if #team_list == 0 then error ('At least one team required') end
	for r=1,#team_list do
		ptsbyrank[r] = tonumber(stripwhitespace(args['pts_'..require('Module:Ordinal')._ordinal(r)] or '')) or defaultpts[r] or 0
	end
	return buildtable(frame,args,team_list,division,ptsbyrank,showmedals,ovptsonly,sumsonly,isfinal)
end

return p