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 10: Line 10:
function p._header(args, options)  
function p._header(args, options)  
if mw.site.namespaces ~= 100 then  
if mw.site.namespaces ~= 100 then  
gallery_text = "[[" .. title.rootText .. "|Gallery]]"  
gallery_text = "[[" .. title.text .. "|Gallery]]"  
else  
else  
gallery_text = "Gallery"  
gallery_text = "Gallery"  

Revision as of 23:13, 27 February 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 then 
			gallery_text = "[[" .. title.text .. "|Gallery]]" 
		else 
			gallery_text = "Gallery" 
		end
		
		if mw.site.namespaces ~= 14 then 
			category_text = "[[" .. mw.title .. "|Category]]" 
		else 
			category_text = "Category" 
		end
		
		if mw.site.namespaces ~= 1 then 
			article_text = "[[" .. mw.site.title .. "|Article]]" 
		else 
			article_text = "Article" 
		end
		
	local article_cell = mw.html.create( 'td' )
     :css( 'width', '33%' )
     :wikitext( article_text )
     
     local series_cell = mw.html.create( 'td' )
     :wikitext( category_text )
     
     local next_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:wikitext( tostring(row)  )

return tostring( t )
end	

return p