擴展:DynamicPageList (Wikimedia)
![]() 发行状态: 穩定版 |
|
---|---|
实现 | 标签 , 解析器函数 |
描述 | 輸出最近進入分類項目的符號列表,或多個分類的交集。 |
作者 | IlyaHaykinson and Amgine |
最新版本 | Continuous updates |
兼容性政策 | 快照跟随MediaWiki发布。 master分支不向后兼容。 |
MediaWiki | 1.23+ |
PHP | 5.4+ |
数据库更改 | 否 |
许可协议 | GNU通用公眾授權條款2.0或更新版本 |
下載 | |
示例 |
|
|
|
<DynamicPageList> |
|
正在使用的公开wiki数 | 813 (Ranked 314th) |
翻译DynamicPageList (Wikimedia)扩展 | |
問題 | 开启的任务 · (Wikimedia) 报告错误 |
- 此擴展被Wikimedia使用,不要和Extension:DynamicPageList (third-party) 擴展或扩展:DynamicPageList (Wikimedia) 混淆。
DynamicPageList擴展讓Wiki用戶建立頁面列表來列出一組分類中的頁面。有關一般信息請見m:幫助:DPL。
起源
It was originally developed for Wikinews. It is currently installed on most language Wikinews projects (see n:Wikinews:DynamicPageList), Meta, MediaWiki.org, and a few other small projects. It will not be installed on any more Wikimedia wikis due to performance issues.
This extension was previously known as DynamicPageList/old and later Intersection. You may also be interested in DynamicPageList3 , which has more features.
安装和设置
安裝
- 下载文件,并将其放置在您
extensions/
文件夹中的intersection
目录内。 - 将下列代码放置在您的LocalSettings.php 的底部:
wfLoadExtension( 'intersection' );
完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。
致使用MediaWiki 1.27或更早版本的用户:
上面的说明介绍的是安装此扩展的新方法,它使用wfLoadExtension()
。
如果您需要在早期版本(MediaWiki 1.27和更早版本)中安装此扩展,而不是wfLoadExtension( 'intersection' );
,您需要使用:
require_once "$IP/extensions/intersection/intersection.php";
配置
The extension also supports a couple of configuration variables. Normally you wouldn't want to change the default, but if you do you can add them to your "LocalSettings.php" after the require_once line. Here is the supported configuration variables along with their default values:
# Configuration variables. Warning: These use DLP instead of DPL
# for historical reasons (pretend Dynamic list of pages)
$wgDLPmaxCategories = 6; // Maximum number of categories to look for
$wgDLPMaxResultCount = 200; // Maximum number of results to allow
$wgDLPAllowUnlimitedResults = false; // Allow unlimited results
$wgDLPAllowUnlimitedCategories = false; // Allow unlimited categories
// How long to cache pages using DPL's in seconds. Default to 1 day. Set to
// false to use the normal amount of page caching (most efficient), Set to 0 to disable
// cache altogether (inefficient, but results will never be outdated)
$wgDLPMaxCacheTime = 60*60*24; // How long to cache pages in seconds
使用
DynamicPageList can be used with XML-like syntax in the wiki edit view. The parameters control the pages to list, order, and display mode. See the following sections for information on each parameter. For example, the following are the oldest five pages on this wiki that were recently moved to MediaWiki.org.
<DynamicPageList> category = Pages recently transferred from Meta count = 5 order = ascending addfirstcategorydate = true </DynamicPageList>
An example of a really complex DynamicPageList:
<DynamicPageList> category=foo count=20 namespace=file addfirstcategorydate=ymd imagewidth=70 galleryshowfilesize=yes galleryshowfilename=yes imagesperrow=7 gallerycaption=Galleries! ordermethod=sortkey order=ascending mode=gallery offset=12 </DynamicPageList>
Lists the 12th to the 31st pages in the file namespace that are also in category foo, formatting them into an image gallery, with the date they were added to category foo in the caption in year month day format, and having the images have a width of 70px
選擇頁面
category
category列出要交集的分類。DynamicPageList將會列出在所有分類都能找到的頁面,要列出的最小和最大頁面數在擴展源代碼中被設定,你可以在分類名稱中使用魔術字,例如{{CURRENTMONTHNAME}}。
語法為category = 分類名稱
<DynamicPageList> category = Demo category = Demo 1 </DynamicPageList>
notcategory
notcategory可以限制頁面列表不在特定分類中,你可以在分類名稱中使用魔術字,例如{{CURRENTMONTHNAME}}。
<DynamicPageList> category = Demo notcategory = Demo 1 </DynamicPageList>
namespace
namespace將上面指定的頁面列表限制在特定命名空間中,使用名稱或編號指定(請參閱預設命名空間列表)。任何無效名稱將等效於主條目命名空間。
<DynamicPageList> category = Demo namespace = Help </DynamicPageList>
redirects
redirects指定是否包含重定向頁面。 The value can be exclude (default, don't list redirects), include (list redirects), or only (don't list pages that aren't redirects).
<DynamicPageList> category = Demo redirects = only </DynamicPageList>
stablepages
stablepages determines whether or not to include stable (flagged) pages when using Extension:FlaggedRevisions . The value can be exclude (don't list), include (list stable and non-stable. default), or only (only list stable pages). Requires FlaggedRevs to be installed to work.
qualitypages
qualitypages determines whether or not to include quality (flagged at the 'pristine' level) pages when using Extension:FlaggedRevisions . The value can be exclude (don't list), include (list both quality and non-quality), or only (only list quality pages).
Note: the behaviour of qualitypages changed from older versions. In older versions qualitypages=exclude automatically made stablepages=only be set. This is no longer the case.
count
count限制顯示的結果數。預設情況下會顯示最近添加到分類的頁面(請參閱排序)。請注意,該擴展不會列出比擴展源代碼中所定義的最大值更多的結果。
<DynamicPageList> category = Demo count = 2 </DynamicPageList>
offset
offset能夠設定頁面項目列表的起始位置。 For example, this can be used with count to make multi-column layouts.
<DynamicPageList> category = Demo offset = 2 </DynamicPageList>
欄示例
<table> <tr><th colspan="3"> recent articles in [[:category:Demo|:category:Demo]]</th></tr> <tr><td> <DynamicPageList> category = Demo count=5 </DynamicPageList> </td> <td> <DynamicPageList> category = Demo offset = 5 count= 5 </DynamicPageList> </td> <td> <DynamicPageList> category = Demo offset = 10 count=5 </DynamicPageList> </td></tr></table>
顯示細節
shownamespace
shownamespace顯示命名空間在頁面名稱中。此值可以是「true」(預設,顯示在名稱中:幫助:目录)或「false」(不顯示在名稱中:目录)。
The value can be true
(default, display in name: Help:Contents ) or false
(don't display in name: Contents ).
<DynamicPageList> category = Demo shownamespace = false </DynamicPageList>
addfirstcategorydate
addfirstcategorydate顯示每個頁面加入分類的日期。此值可以是「true」(顯示日期)、「false」(預設,不顯示日期)或日期指示浮(ymd、md、dm、dmy、mdy或ISO 8601)。如果指定了多個分類,則使用第一個分類。在頁面名稱前方顯示的日期格式由您本地的MediaWiki日期格式偏好決定。
<DynamicPageList> category = Demo addfirstcategorydate = true </DynamicPageList>
mode
mode指定列表格式,此值可以是:
- unordered — 項目符號列表
- ordered — 編號列表
- none — 帶有換行的純連結
- gallery — 圖庫,就像是
<gallery>
- inline — 逗號分隔列表
unordered: <DynamicPageList> category = Demo mode = unordered </DynamicPageList> 編號: <DynamicPageList> category = Demo mode = ordered </DynamicPageList> 純連結: <DynamicPageList> category = Demo mode = none </DynamicPageList> 逗號分隔: <DynamicPageList> category = Demo mode = inline </DynamicPageList>
mode=gallery
Gallery is a special mode where the output is an image gallery. If Extension:页面图片 is installed, then the page-image if one exists will be used for non-file pages. Otherwise non-File namespace pages will just be a blank space.
<DynamicPageList> category = Demo mode = gallery namespace= file </DynamicPageList>
Gallery mode also supports the options imagewidth (how wide the images should be in gallery, you may need to also set imageheight if using this), imageheight (how high the image should be) galleryshowfilesize (show the image size, like on category pages), galleryshowfilename (show filename like on category pages), imagesperrow (number of images per row in gallery), gallerycaption (caption for gallery).
If addfirstcategorydate is in use, the date is appended to the caption of the image.
Note, gallerycaption at the moment cannot accept links. (but it can accept things like {{CURRENTMONTHNAME}})
A complex gallery example might be:
<DynamicPageList> count=20 namespace=file addfirstcategorydate=ymd imagewidth=70 galleryshowfilesize=yes galleryshowfilename=yes imagesperrow=7 gallerycaption=Look at my pretty gallery. mode=gallery shownamespace=false </DynamicPageList>
suppresserrors
suppresserrors用以隱藏錯誤。此值可以為「true」(隱藏錯誤)或「false」(預設,顯示錯誤)。
true: <DynamicPageList> category = Dem suppresserrors = true </DynamicPageList> false: <DynamicPageList> category = Dem suppresserrors = false </DynamicPageList>
nofollow
nofollow sets rel="nofollow"
on the links.
This prevents spiders from getting to the page through the link from the DynamicPageList.
In general this is useless, as spiders will either be able to index the page from other links, or not at all due to robots.txt/$wgDefaultRobotPolicy .
In general you should not use this option unless you know what you are doing, and have a good reason.
The primary usecase is that on the English Wikinews, Google News considers anything linked from the main page to be an article.
<DynamicPageList> category = Demo nofollow = true </DynamicPageList>
googlehack
This is a hack for wikinews. Previously, Google News only considered articles with numbers in them to be news articles [1], so this appends ?dpl_id=<id of article> to the end of the urls on the list. You shouldn't use this option unless you have a good reason to (however it won't hurt anything). This replaces the showcurid option that is no longer supported.
<DynamicPageList> category = Demo googlehack = true </DynamicPageList>
排序
ordermethod
ordermethod指定排序及顯示日期,此值可以是:
- categoryadd — 預設,以頁面加入第一個分類的日期排序
- lastedit — 以頁面最後編輯時間排序
- length — 以頁面長度排序
- created — 以頁面建立時間排序
- categorysortkey — 基本上按照第一個分類的排序字以字母順序排序
- sortkey — categorysortkey的別名
It should be noted, that lastedit really sorts by the last time the page was touched.
In some cases this is not equivalent to the last edit (for example, this includes permission changes, creation or deletion of linked pages, and alteration of contained templates).
If you do not specify a category, some of these order methods will not work—specifically, categoryadd and categorysortkey fallback to created if there is no category
clause.
<DynamicPageList> category = Demo addfirstcategorydate = true ordermethod = lastedit </DynamicPageList>
按字母順序範例:
<DynamicPageList> category = Demo ordermethod = sortkey </DynamicPageList>
order
order決定排序方向。 The value can be descending (default, most recent to oldest) or ascending (oldest to most recent).
<DynamicPageList> category = Demo order = ascending </DynamicPageList>
模板
To use inside a template and pass parameters, use parser functions etc., use the {{#tag:
function:
{{#tag:DynamicPageList| category = {{{1}}} count = {{#if: {{{2|}}} | 10 | 20 }} ordermethod = sortkey order = ascending }}
The template page itself will display an error message because the category value is empty on the template page unless you put the template inside <includeonly>
tags. Example:
错误:需要包含至少一个分类,或指定一个命名空间!
衍生扩展
- Derived extensions: DPLforum outputs in forum style. Extension:GoogleNewsSitemap is like this but outputs an RSS feed. DynamicPageList (third-party) is a modified version with more features, but also more resource-expensive. Neither of the latter is used on Wikimedia's sites.
- Version 1.8.4 of DynamicPageList (third-party) is fully downward compatible with the extension described here. So the way is open for a re-unification of the different development paths. This is not true any more for the current versions since version 2.01 of DynamicPageList (third-party) does not support
ordermethod=sortkey
. - 扩展:DynamicPageListEngine - makes dynamic page lists available to Scribunto modules.
![]() | 此扩展用于一个或多个维基媒体项目。 这可能意味着扩展足够稳定、运作足够良好,可以用在这样的高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中查找此扩展的名称以查看哪些网站安装了该扩展。 特定wiki上的已安装的扩展的完整列表位于Special:Version页面。 |
![]() | 此扩展在以下wiki农场/托管网站和/或软件包中提供: 這不是一份權威名單。 即使某些wiki农场/托管网站和/或软件包未在这里列出,它们也可能提供此扩展。 请检查你的wiki农场/托管网站或软件包以确认提供情况。 |
- Stable extensions/zh
- Tag extensions/zh
- Parser function extensions/zh
- GPL licensed extensions/zh
- Extensions in Wikimedia version control/zh
- ParserFirstCallInit extensions/zh
- All extensions/zh
- Extensions used on Wikimedia/zh
- Extensions included in Miraheze/zh
- Extensions included in WikiForge/zh
- Extensions included in WikiTide/zh
- Page content extensions/zh
- Category intersection extensions/zh