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:NewsLanding
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 getArgs = require('Module:Arguments').getArgs local cargo = mw.ext.cargo local NewsLanding = {} local limit = 25 function NewsLanding.main(frame) local args = getArgs(frame) if args.more then return NewsLanding.html(args.page or 1) end local tableContainer = mw.html.create('div') tableContainer:node(mw.html.create('h2'):wikitext('Latest news')) local listContainer = mw.html.create('div'):attr('id', 'list__container') tableContainer:node(listContainer) local html = NewsLanding.html(args.page or 1) if html == nil or html == '' then return tableContainer:wikitext('No news in the database') else listContainer:node(html) local loadMore = frame:callParserFunction{ name = '#widget', args = { 'Pagination', id = 'list__container', template = 'NewsLanding'} } tableContainer:node(loadMore) end return tableContainer end function NewsLanding.query(page) local tables = 'News' local fields = '_pageName, date' local cargoArgs = { orderBy = 'date DESC', limit = limit, offset = (page - 1) * limit } local results = cargo.query(tables, fields, cargoArgs) return results end function NewsLanding.html(page) local results = NewsLanding.query(page) local list = '' if #results > 0 then for i = 1, #results do local result = results[i] local dateString = mw.ustring.gsub(result.date, "%s(AM|PM)$", "") -- Use os.date to convert the string to a table of date and time components local dateTimeTable = os.date("*t", os.time({year=string.sub(dateString, 1, 4), month=string.sub(dateString, 6, 7), day=string.sub(dateString, 9, 10), hour=tonumber(string.sub(dateString, 12, 13)) + ((string.sub(dateString, 22, 22) == "PM") and 12 or 0), min=string.sub(dateString, 15, 16), sec=string.sub(dateString, 18, 19)})) -- Use os.date again to format the date and time components into a desired format local formattedDate = os.date("%d %b %Y %H:%M", os.time(dateTimeTable)) local news = mw.html.create('div'):wikitext(formattedDate .. ' - [[' .. result._pageName .. ']]') list = list .. tostring(news) end else return nil end return list end return NewsLanding
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:NewsLanding/doc
(
edit
)
No categories
Edit