Module:InfoboxPht

Revision as of 06:50, 27 May 2026 by Parvej (talk | contribs) (Created page with "local p = {} local function row(label, value) if value and value ~= "" then return string.format( '<tr><th style="text-align:left; padding:6px; width:40%%; background:#f2f2f2;">%s</th><td style="padding:6px;">%s</td></tr>', label, value ) end return "" end function p.infobox(frame) local args = frame:getParent().args -- Basic info local name = args.name or mw.title.getCurrentTitle().text local image = args.image local caption = args.caption -- P...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

local function row(label, value) if value and value ~= "" then return string.format(

'%s%s',

label, value ) end return "" end

function p.infobox(frame) local args = frame:getParent().args

-- Basic info local name = args.name or mw.title.getCurrentTitle().text local image = args.image local caption = args.caption

-- Personal details local gender = args.gender local age = args.age local birth_name = args.birth_name local birth_date = args.birth_date local birth_place = args.birth_place local died = args.died local parents = args.parents local relatives = args.relatives local nationality = args.nationality local other_names = args.other_names local occupation = args.occupation local years_active = args.years_active local known_for = args.known_for local notable_works = args.notable_works local home_town = args.home_town local education = args.education local alma_mater = args.alma_mater local awards = args.awards local spouse = args.spouse local children = args.children local religion = args.religion local political_affiliation = args.political_affiliation local residence = args.residence local website = args.website local social_media = args.social_media

-- Attributes local height = args.height local weight = args.weight local hair = args.hair local eyes = args.eyes

-- Main container local html = mw.html.create("div") :addClass("infobox vcard") :css({ width = "22em", border = "1px solid #3366cc", margin = "10px", float = "right", background = "#f9f9f9", ["font-size"] = "88%" })

local tbl = html:tag("table") :css({ width = "100%", ["border-collapse"] = "collapse" })

-- Title tbl:tag("tr") :tag("th") :attr("colspan", "2") :css({ background = "#3366cc", color = "white", ["text-align"] = "center", ["font-size"] = "18px", padding = "8px" }) :wikitext(name)

-- Image if image and image ~= "" then tbl:tag("tr") :tag("td") :attr("colspan", "2") :css({ ["text-align"] = "center", padding = "8px" }) :wikitext(string.format("File:%s", image)) end

-- Caption if caption and caption ~= "" then tbl:tag("tr") :tag("td") :attr("colspan", "2") :css({ ["text-align"] = "center", ["font-style"] = "italic", padding = "4px" }) :wikitext(caption) end

-- Personal Information Header tbl:tag("tr") :tag("th") :attr("colspan", "2") :css({ background = "#3366cc", color = "white", ["text-align"] = "center", padding = "6px" }) :wikitext("Personal Information")

-- Personal Information Rows tbl:wikitext(row("Gender", gender)) tbl:wikitext(row("Age", age)) tbl:wikitext(row("Born", birth_name)) tbl:wikitext(row("Birth date", birth_date)) tbl:wikitext(row("Birth place", birth_place)) tbl:wikitext(row("Died", died)) tbl:wikitext(row("Parents", parents)) tbl:wikitext(row("Relatives", relatives)) tbl:wikitext(row("Nationality", nationality)) tbl:wikitext(row("Other names", other_names)) tbl:wikitext(row("Occupation", occupation)) tbl:wikitext(row("Years active", years_active)) tbl:wikitext(row("Known for", known_for)) tbl:wikitext(row("Notable work(s)", notable_works)) tbl:wikitext(row("Home town", home_town)) tbl:wikitext(row("Education", education)) tbl:wikitext(row("Alma mater", alma_mater)) tbl:wikitext(row("Awards / Honors", awards)) tbl:wikitext(row("Spouse / Partner", spouse)) tbl:wikitext(row("Children", children)) tbl:wikitext(row("Religion", religion)) tbl:wikitext(row("Political affiliation", political_affiliation)) tbl:wikitext(row("Residence", residence)) tbl:wikitext(row("Website", website)) tbl:wikitext(row("Social media", social_media))

-- Attributes Header if height or weight or hair or eyes then tbl:tag("tr") :tag("th") :attr("colspan", "2") :css({ background = "#3366cc", color = "white", ["text-align"] = "center", padding = "6px" }) :wikitext("Attributes")

tbl:wikitext(row("Height", height)) tbl:wikitext(row("Weight", weight)) tbl:wikitext(row("Hair color", hair)) tbl:wikitext(row("Eye color", eyes)) end

return tostring(html) end

return p