Homepage
Games
News
News βΎ
All
Transfers
Drama
Business
Sponsors
Mergers
Investors
Hires
Companies
More
People
Tournaments
Brands
Brands βΎ
Companies
Organizations
Sponsors
Other
Locations
Search
Editing
Module:CompanyLanding
From TwogPedia
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local cargo = mw.ext.cargo local VariablesLua = mw.ext.VariablesLua local getArgs = require('Module:Arguments').getArgs local p = {} local limit = 25 function p.Main(frame) local args = getArgs(frame) if args.more then return p.html(args.page or 1) end local tableContainer = mw.html.create('div') -- tableContainer:node(mw.html.create('h2'):wikitext('Companies')) local listContainer = mw.html.create('div'):attr('id', 'list__container') tableContainer:node(listContainer) local html = p.html(args.page or 1) if html == nil or html == '' then return tableContainer:wikitext('No companies in the database') else listContainer:node(html) local loadMore = frame:callParserFunction{ name = '#widget', args = { 'Pagination', id = 'list__container', template = 'CompanyLanding'} } tableContainer:node(loadMore) end return tableContainer end function p.query(page) local tables = 'Companies' local fields = '_pageName, country' local cargoArgs = { limit = limit, offset = (page - 1) * limit, orderBy = '_pageName ASC' -- orderBy = 'SUBSTRING(_pageName, LENGTH("Companies/" + 1)' } local results = cargo.query(tables, fields, cargoArgs) return results end function p.html(page) local results = p.query(page) local list = '' local ulDiv = mw.html.create('div') if #results > 0 then local pageDisplayName = string.gsub(results[1]._pageName, 'Companies/', '') local letter = VariablesLua.varexists('firstLetter') and VariablesLua.var('firstLetter') or string.upper(string.sub(pageDisplayName, 1, 1)) if VariablesLua.varexists('firstLetter') and VariablesLua.var('firstLetter') ~= string.upper(string.sub(pageDisplayName, 1, 1)) then list = list .. tostring(mw.html.create('div'):css('font-weight', '800'):wikitext(letter)) end if page == 1 then list = list .. tostring(mw.html.create('div'):css('font-weight', '800'):wikitext(letter)) end for i = 1, #results do local result = results[i] pageDisplayName = mw.ext.displaytitle.get(result._pageName) local firstLetter = string.upper(string.sub(pageDisplayName, 1, 1)) -- Create new list for entries with next starting letter if firstLetter ~= letter then list = list .. tostring(mw.html.create('div'):css('font-weight', '800'):wikitext(firstLetter)) letter = firstLetter end local company = mw.html.create('li'):wikitext('[[' .. result._pageName .. ']]') list = list .. tostring(company) end VariablesLua.vardefine('firstLetter', letter) else return nil end return list end return p
Summary:
Please note that all contributions to TwogPedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TwogPedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:CompanyLanding/doc
(
edit
)
No categories
Edit