Bước tới nội dung

Mô đun:Category see also if exists

Bách khoa toàn thư mở Wikipedia
--[[ v1.0]]local p = {}function doesCatExist(catname)	local catPage = mw.title.new( catname, "Category" )	if catPage == nil then		return false	end	if catPage.exists then		return true	end	return falseendfunction p.main(frame)	local rawcats = {}	local nvalid = 0	for i, v in ipairs(mw.getCurrentFrame():getParent().args) do		if (v ~= nil) then			local thisArg = mw.text.trim(v)			thisArg = mw.ustring.gsub(thisArg, "^Category:%s*", "", 1)			if (thisArg ~= "") then				if ( doesCatExist(thisArg)) then					table.insert(rawcats, "Thể loại:" .. thisArg)					nvalid = nvalid + 1				end			end		end	end	if (nvalid == 0) then		mw.addWarning("'''[[Bản mẫu:Category see also if exists]] — không có đầu ra, vì các thể loại này chưa tồn tại.'''")		return ""	end	local mLabelledList = require('Module:Labelled list hatnote')	local pages = mLabelledList._labelledList(rawcats, "Xem thêm", "")	return pagesendreturn p