Module:BuildingBreadcrumb
From Dune Awakening DB
Documentation for this module may be created at Module:BuildingBreadcrumb/doc
local p = {}
function p.render(frame)
local title = mw.title.getCurrentTitle().text
local rows = mw.ext.externalData.getExternalData({
source = "externaldb",
from = "data_buildings",
where = "page_title='" .. title:gsub("'", "''") .. "'",
data = "category_1=category_1,category_2=category_2,category_3=category_3"
})
if not rows or #rows == 0 then
return ''
end
local cat1 = rows[1].category_1 or ''
local cat2 = rows[1].category_2 or ''
local cat3 = rows[1].category_3 or ''
local Html = mw.html
local html = Html.create('div'):addClass('dune-breadcrumb-nav')
html:tag('a')
:attr('id', 'duneLogoBtn')
:addClass('dune-logo-btn')
:tag('img')
:attr('src', 'https://dunedb.com/images/9/99/HomeNavIcon.png')
:attr('alt', 'DuneDB Logo')
:addClass('dune-logo')
:done()
:done()
html:tag('a')
:attr('href', 'https://dunedb.com/Main_Page')
:addClass('breadcrumb-home-link')
:wikitext('<span>Home</span>')
:done()
local function addLink(label, link)
html:tag('span'):addClass('dune-breadcrumb-separator'):wikitext('/'):done()
html:tag('a'):attr('href', link):wikitext(label):done()
end
if cat1 ~= '' then
addLink(cat1, 'https://dunedb.com/wiki/' .. mw.uri.encode(cat1, 'PATH'))
end
if cat2 ~= '' then
addLink(cat2, 'https://dunedb.com/wiki/' .. mw.uri.encode(cat2, 'PATH'))
end
if cat3 ~= '' then
addLink(cat3, 'https://dunedb.com/wiki/' .. mw.uri.encode(cat3, 'PATH'))
end
return tostring(html)
end
return p
