Site notice
Welcome! Please check To-Do List to see what pages need help, who is working on what, etc.

Difference between revisions of "Module:Header"

From Mega Man Wiki
Line 46: Line 46:
     t:css( 'width', '100%' )
     t:css( 'width', '100%' )
     t:css( 'margin-bottom', '0px;')
     t:css( 'margin-bottom', '0px;')
    t:css( 'margin-top', '0px;')
     t:wikitext( tostring(row)  )
     t:wikitext( tostring(row)  )



Revision as of 23:41, 30 April 2021

Documentation for this module may be created at Module:Header/doc

local p = {} --p stands for package

function p.header(frame)
	-- A passthrough that gets args from the frame and all
	mArguments = require('Module:Arguments')
	args = mArguments.getArgs(frame)
	return p._header(args)
end

function p._header(args, options) 
	if mw.site.namespaces ~= 100 and args["title"] ~= nil then 
		gallery_text = "[[Gallery:" .. args["title"] .. "|Gallery]]" 
	else 
		gallery_text = "Gallery" 
	end
	
	if mw.site.namespaces ~= 14 and args["title"] ~= nil then 
		category_text = "[[:Category:" .. args["title"] .. "|Category]]" 
	else 
		category_text = "Category" 
	end
	
	if mw.site.namespaces ~= 0 and args["title"] ~= nil  then 
		article_text = "[[" .. args["title"] .. "|Article]]" 
	else 
		article_text = "Article" 
	end
	
	local article_cell = mw.html.create( 'td' )
     :css( 'width', '33%' )
     :wikitext( article_text )
     
     local category_cell = mw.html.create( 'td' )
     :wikitext( category_text )
     
     local gallery_cell = mw.html.create( 'td' )
     :css( 'width', '33%' )
     :wikitext( gallery_text )
     
local row = mw.html.create( 'tr' )
     :wikitext( tostring(article_cell) .. tostring(category_cell) .. tostring(gallery_cell)  )
     
     
local t = mw.html.create( 'table' )
     t:addClass( "wikitable")
     t:css( 'width', '100%' )
     t:css( 'margin-bottom', '0px;')
     t:css( 'margin-top', '0px;')
     t:wikitext( tostring(row)  )

return tostring( t )
end	

return p