Actions

Template

WeaponBreadcrumbs: Difference between revisions

From Dune Awakening DB

Created page with "local p = {} function p.render(frame) local Html = mw.html local titleObj = mw.title.getCurrentTitle() local currentTitle = titleObj.text local rows = mw.ext.externalData.getExternalData({ source = "externaldb", from = "data_weapons", where = "page_title='" .. currentTitle:gsub("'", "''") .. "'", data = "category_1=category_1,category_2=category_2,category_3=category_3" }) local cat1, cat2, cat3 if rows and #rows > 0 then cat1 = rows[..."
 
mNo edit summary
Tag: Manual revert
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
{{#invoke:WeaponBreadcrumb|render}}
 
function p.render(frame)
  local Html = mw.html
  local titleObj = mw.title.getCurrentTitle()
  local currentTitle = titleObj.text
 
  local rows = mw.ext.externalData.getExternalData({
    source = "externaldb",
    from = "data_weapons",
    where = "page_title='" .. currentTitle:gsub("'", "''") .. "'",
    data = "category_1=category_1,category_2=category_2,category_3=category_3"
  })
 
  local cat1, cat2, cat3
  if rows and #rows > 0 then
    cat1 = rows[1].category_1 or ''
    cat2 = rows[1].category_2 or ''
    cat3 = rows[1].category_3 or currentTitle
  else
    cat1 = 'Weapons'
    cat2 = 'Uncategorized'
    cat3 = currentTitle
  end
 
  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 addCrumb(label)
    html:tag('span'):addClass('dune-breadcrumb-separator'):wikitext('/'):done()
    html:tag('a')
      :attr('href', 'https://dunedb.com/wiki/' .. mw.uri.encode(label, 'PATH'))
      :wikitext(label)
    :done()
  end
 
  if cat1 ~= '' then addCrumb(cat1) end
  if cat

Latest revision as of 22:33, 9 April 2025

<a id="duneLogoBtn" class="dune-logo-btn"><img src="https://dunedb.com/images/9/99/HomeNavIcon.png" alt="DuneDB Logo" class="dune-logo" /></a><a href="https://dunedb.com/Main_Page" class="breadcrumb-home-link">Home</a>/<a href="https://dunedb.com/wiki/Weapons">Weapons</a>/<a href="https://dunedb.com/wiki/Uncategorized">Uncategorized</a>/WeaponBreadcrumbs