跳转到内容

模組:Carousel/doc

维基百科,自由的百科全书

这是本页的一个历史版本,由PhiLiP留言 | 贡献2017年3月4日 (六) 23:58 Step 1: 创建JSON页面编辑。这可能和当前版本存在着巨大的差异。

这是Module:Carousel的文档页面

页面轮展模块,可用于首页特色条目、优良条目展示。

用法

Step 1: 创建JSON页面

首先,需要创建一个JSON页面,其中记录了要轮展嵌入的页面,以及轮展的顺序。以下是一个例子(User:PhiLiP/carousel-example.json):

[
    {
        "title": "1689年波士顿起义",
        "displayTimeRanges": [
            [
                20150304123013,
                null
            ]
        ]
    },
    {
        "title": "1850年大西洋飓风季",
        "displayTimeRanges": [
            [
                20141030151730,
                null
            ]
        ]
    },
    {
        "title": "1873年铸币法案",
        "displayTimeRanges": [
            [
                20160805143015,
                null
            ]
        ]
    },
    {
        "title": "1880年民主党全国大会",
        "displayTimeRanges": [
            [
                20141213150114,
                null
            ]
        ]
    }
]

Step 2: 调用轮展模块

效果(当前Unix时间戳为1748492199,应展示第3条):

Lua错误:expandTemplate: template "Wikipedia:特色条目/1873年铸币法案" does not exist。

在要显示轮展内容的位置,按下述方式调用模块:

{{#invoke:Carousel|main|candidateList=User:PhiLiP/carousel-example.json}}

可选参数

效果(当前Unix时间戳为1748492199,应展示第4条):

Lua错误:bad argument #2 to 'formatDate': invalid timestamp '86400'。

除了candidateList外,有两个可选参数timeStarttimeIntervaltimeStart定义轮展的起始时间(以秒级Unix时间戳规定的UTC时间,默认值0,即UTC时间1970年1月1日0时0分0秒);timeInterval定义每轮展示的秒数(默认值86400秒,即1天)。下为示例:

<!-- 从UTC时间1970年1月2日0时0分0秒起,每小时更换一次 -->
{{#invoke:Carousel|main|candidateList=User:PhiLiP/carousel-example.json|timeStart=86400|timeInterval=3600}}