Dokumentācijas ikona Moduļa dokumentācija[skatīt] [labot] [hronoloģija] [pārlādēt]

Piemēri labot šo sadaļu

Kods Rezultāts
{{#invoke:Lapas ID|main|40|81298}}
  • 40: Sākumlapa
  • 81298: Dalībnieks:Edgars2007
{{#invoke:Lapas ID|main|26096242|46872837}}
  • Nav lapas ar šādu ID 26096242
  • Nav lapas ar šādu ID 46872837

Piezīmes labot šo sadaļu

Ja tiks izsaukts kādas lietotāja lapas ID, tā tiks uztverta kā vikisaite, līdz ar to kopā ar parakstu dažās vārdtelpās tas var ģenerēt paziņojumu.

local p = {}
 
function p.main(frame)
	local out = {}
	for k,v in ipairs(frame.args) do
		local id = tonumber(v)
		if not id then
			error(string.format("Nederīgs lapas ID %s", v))
		end
		local title = mw.title.new(id)
		if title then
			out[k] = string.format("* %d: %s\n", title.id, title.prefixedText)
		else
			out[k] = string.format("* Nav lapas ar šādu ID %d\n", id)
		end
	end
	return table.concat(out)
end

function p.main2(frame)
	local out = {}
	for k,v in ipairs(frame.args) do
		local id = tonumber(v)
		if not id then
			error(string.format("Nederīgs lapas ID %s", v))
		end
		local title = mw.title.new(id)
		if title then
			out[k] = string.format("%s\n", title.prefixedText)
		else
			out[k] = string.format("* Nav lapas ar šādu ID %d\n", id)
		end
	end
	return table.concat(out)
end

return p