打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

Module:SubpageTable:修订间差异

来自OTTOWiki
琪露若
琪露若留言 | 贡献 (debug)
 
(未显示同一用户的1个中间版本)
第3行: 第3行:
function p.table(frame)
function p.table(frame)
     local currentTitle = mw.title.getCurrentTitle()
     local currentTitle = mw.title.getCurrentTitle()
    local args = frame.args
      
      
     -- 参数处理
     -- 获取子页面的另一种方法
     local limit = args.limit or '50'
     local result = frame:preprocess('{{Special:PrefixIndex/' .. currentTitle.prefixedText .. '/|hideredirects=1|stripprefix=1|format=table}}')
    local class = args.class or 'wikitable sortable'
    local namespace = args.namespace or currentTitle.namespace
      
      
     -- 使用 DPL 查询子页面
     -- 如果返回空,添加提示
     local dplQuery = {
     if result == "" then
        'namespace = ' .. namespace,
         return "此页面没有子页面。"
        'titlematch = ' .. currentTitle.prefixedText .. '/%',
     end
        'mode = userformat',
         'listseparators = {| class="' .. class .. '"\n! 页面名称\n! 最后修改\n! 大小\n|-,\n| [[%PAGE%]]\n| %DATE%\n| %SIZE% 字节,\n|-,\n|}',
        'ordermethod = title',
        'order = ascending',
        'count = ' .. limit,
        'suppresserrors = true'
     }
      
      
    -- 构建 DPL 标签
     return result
    local dplTag = '<dpl>\n' .. table.concat(dplQuery, '\n|') .. '\n</dpl>'
   
    -- 执行 DPL
     return frame:preprocess(dplTag)
end
end


return p
return p

2025年10月3日 (五) 01:27的最新版本

local p = {}

function p.table(frame)
    local currentTitle = mw.title.getCurrentTitle()
    
    -- 获取子页面的另一种方法
    local result = frame:preprocess('{{Special:PrefixIndex/' .. currentTitle.prefixedText .. '/|hideredirects=1|stripprefix=1|format=table}}')
    
    -- 如果返回空,添加提示
    if result == "" then
        return "此页面没有子页面。"
    end
    
    return result
end

return p