allwiki首页  
天下维客 你可以修改的网络知识库
首页最近更改优秀条目专题展示电脑科技词典软件学习网络知识电脑安全明星时尚天下百科
 

MediaWiki扩展:动态页面列表2

天下维客,你可以修改的网络知识库

Jump to: navigation, search

本文取自元维基,欢迎共同翻译、整理与大家共享,促进中文wiki发展^_^

DynamicPageList2 is a Mediawiki extension developed for use on Wikinews, but it can be installed on any wiki. It allows wiki users to dynamically create lists of pages that are listed in a set of categories or namespaces using logical AND and OR.

目录

DynamicPagelist2 or 1

This is a hack of the original DynamicPageList extension from DynamicPageList featuring many Improvements (see below). Note that it's called DynamicPageList2 for distinction of DynamicPageList. You can use both extensions at the same time, because the new tag is DPL instead of DynamicPageList.

With DPL2 you have much more freedom when constructing articlelists by using AND and OR with categories. en plus, there are much more display options to set.

Source and Installation

http://tucholsky.diebin.at/~fabian/DynamicPageList2.php.txt

To install it, put the file in your extensions/ directory, and add

include("extensions/intersection/DynamicPageList2.php");
to your LocalSettings.php file.

If you are using this extension on a Windows box, make sure to give Read & Execute rights to the user IUSR_MACHINENAME (Anonymous Internet Guest Account) for the extensions directory.

Author

Unendlich (EMail: fabian AT xover.htu.tuwien.ac.at). Bugsreports please per Mail.

MediaWiki Version

The extension works on Mediawiki 1.6.3 and does'nt work on Mediawiki 1.5.x The extension uses (needs) three Parameters and WikiMedia 1.5.x provides only two Parameters.

Usage examples

...Improvements and Changes

Hack v0.3.3

Features:

  • possibility to add the date of the last change
  • possibility to customize the symbol which is used for "ordermethod=inline"

Bugfixes:

  • changed default ordermethod to "title" to fix a usabilitybug when ANDing multiple categories.

Hack v0.3.2

Features:

  • Use the new Cache-Invalidation Trigger as described here: <a href="/wiki/MediaWiki_extensions_FAQ#How_do_I_disable_caching_for_pages_using_my_extension.3F" title="MediaWiki extensions FAQ">MediaWiki extensions FAQ#How do I disable caching for pages using my extension?</a>

Bugfixes:

  • Eliminated a bug while using constructs like Cat1 AND Cat2

Hack v0.3.1

Bugfixes:

  • Eliminated non-initialized variables
  • works with DB prefixes now

Hack v0.3

New features:

  • Possibility to use "inline" as Outputmode, this creates lists like "Item1 - Item2 - Item3".

Changes:

  • No need for the DPL2UncachedPages Article anymore. Every article using DPL will unset it's cache automatically.

Hack v0.2.1

Bugfixes:

  • Fixed a typo in the code which resulted in wrong queries in some configurations

Hack v0.2

New features:

  • Possibility to use "old" DynamicPageList and DynamicPageList2 at the same time. The tag ist called DPL now

Changes:

  • The tag you must use is <DPL> now
  • The category/namespace separator is '|' now instead of ','.
  • Page for uncached Sites ist DPL2UncachedPages now.

Hack v0.1

New features:

  • combine categories using logical OR and AND:
    category=1st,2nd,3rd
    category=4th,5th
means Articles have to be in (1st OR 2nd OR 3rd category) AND (4th OR 5th category)
  • selecting several namespaces using namespace=1st,2nd,3rd... the result will have to be in namespace 1st OR namespace 2nd ...
  • select articles just by namespace without using any categories
  • sort by pagetitle (ordermethod=title)
  • always invalidate cache on certain specified pages (kind of dirty hack, details: http://bugzilla.wikimedia.org/show_bug.cgi?id=2282)
  • output result categorypage-style (mode=category)
  • removed a bug which made ordermethod=lastedit showing wrong results
  • more logical, structured, beautiful and even smaller code:-)

Changes:

  • removed the option $wgDLPMinResultCount in the code, because it made no sense to me. I don't understand how somebody should use an option 'MinResultCount' (you can delimit many results, but you can't increase results...)
  • suppresserrors=true now only suppresses errors about no results, every other error will be shown
  • If you don't use categories or use more than one category and use the options 'addfirstcategorydate=true' or 'ordermethod=categoryadd' an error message appears.

Note that there could still be bugs in there, though it works perfectly for me at the moment. I would be glad to receive comments or bugreports!

Usage of DynamicPageList2

To use DPL, use the following XML-like syntax on your wiki page:

<DPL>
...parameters...
</DPL>

The output of this would be something like: (depending on the outputmode you select)

The list of pages being output, as well as the order and display mode of the list has to match the defined parameters.

The following lists parameters and their effects

category

Purpose:

Include a category in the union of directories. For example, if you include a category parameter, any page being linked to from the output of the DPL has to be in the given categories. You can specify more categories separated by pipes '|' with the effect that the pages listed have to be in one of the categories (logical OR). If you specify the 'category=' parameter more than once, the pages listed have to match all these parameters (logical AND).

Syntax:

category=<i>1st category name|2nd category name|3rd category name|...</i>

Example:

<DPL>
category=Africa|Europe
category=Politics and conflicts
</DPL>

gives on this wiki:

<DPL> category=Africa|Europe category=Politics and conflicts </DPL>

This list will output pages that have [[Category:Africa]] OR [[Category:Europe]] AND [[Category:Politics and conflicts]] listed.

Notes:

The minimum and maximum number of categories required can be set in the extension file at installation time. See down 'Extension options'.

notcategory

Purpose:

Much like the category parameter, but requires that every page listed not be in a particular category. Unlike in 'category' you cannot combine several categories using logical OR in this parameter.

Syntax:

notcategory=<i>category name</i>

Example:

<DPL>
category=Africa
notcategory=Zimbabwe
</DPL>

This list will output pages that have [[Category:Africa]] but do not have [[Category:Zimbabwe]] listed.

namespace

Purpose:

To restrict the articles in the list to only be in one of the given namespaces.

Syntax:

namespace=<i>1st namespaceid or name|2nd namespaceid or name|3rd namespaceid or name|...</i>

The namespaceid may be any positive integer or zero, assuming it represents a valid namespace in the system. The zero namespace is the main article namespace.

Instead of the number, you may also specify a name, for example Talk or Template or User_talk. Any invalid name is equivalent to the main article namespace.

Example:

<DPL>
category=Policy
namespace=Wikinews|Discussion
</DPL>

This list will output pages that are in the Wikinews OR Discussion namespace and belong to [[Category:Policy]].


shownamespace

Purpose:

To restrict the appearance of the namespace name of a page before the page. For example, when this parameter is used, instead of Template:Stub the listing would simply be Stub.

Example:

shownamespace=false

If omitted, the default is true.

Example:

<DPL>
category=Africa
namespace=Talk
shownamespace=false
</DPL>

This list will output all Talk pages in [[Category:Africa]], listed without the Talk: prepended to page names.

mode

Purpose:

To control the output of the DPL.

Syntax:

mode=<i>modename</i>

modename can be one of:

  • unordered — outputs an unordered list — HTML tag "ul" — (default)
  • ordered — outputs an ordered list — HTML tag "ol"
  • none — outputs a list using newlines and HTML tags "br" to separate each item
  • inline — outputs a list using ' - ' to separate items (Item1 - Item2 - Item3)
  • category — outputs resulting articles in a way category-pages are shown (you have to use ordermethod=title if you want to use this option!)

Example:

<DPL>
category=Africa
mode=ordered
</DPL>
This list will output pages that have [[Category:Africa]] shown in an
    ...
list.

order

Purpose:

Controls the sort direction of the list.

Example:

order=<i>orderdirection</i>

orderdirection can be one of:

  • descending — outputs list from most recent to least recent — (default)
  • ascending — outputs list from least recent to most recent

Example:

<DPL>
category=Africa
order=ascending
</DPL>

This list will output pages that have [[Category:Africa]] shown ordered from oldest to newest.

count

Purpose:

Controls the number of results that are shown

Example:

count=<i>number of results</i>

Example:

<DPL>
category=Africa
count=2
</DPL>

This list will output the two most recent pages that have [[Category:Africa]].

Notes:

There is a maximum allowed number of results, controlled by a setting in the extension.

ordermethod

Purpose:

Determines what date is used for ordering the list.

Example:

ordermethod=<i>method</i>

method can be one of:

  • categoryadd — outputs list based on most recent addition to the first category — (default)
  • lastedit — outputs list based on most recent edit to the pages
  • title — outputs list sorted by article title

Example:

<DPL>
category=Africa
ordermethod=lastedit
</DPL>

This list will output pages that have [[Category:Africa]] showing most recently edited articles at the top.

suppresserrors

Purpose:

Allows warnings about empty lists to be suppressed. Every other warning about syntactic mistakes will not be suppressed.

Example:

suppresserrors=true

If omitted, the default is false.

Example:

<DPL>
category=Nonexistent
suppresserrors=true
</DPL>

This list will output no pages since the category is non-existent, but will not show a warning saying the list is empty.

redirects

Purpose:

Controls the inclusion or exlusion of redirect pages in lists.

Example:

redirects=<i>criteria</i>

criteria can be one of:

  • exclude — excludes redirect pages from lists — (default)
  • include — allows redirect pages to appear in lists
  • only — lists only redirect pages in lists


Example:

<DPL>
category=Africa
redirects=include
</DPL>

This list will content pages and redirect pages tagged with [[Category:Africa]].

addfirstcategorydate

Purpose:

Shows the date the article got added to the first listed include category.

Example:

addfirstcategorydate=true

If omitted, the default is false.

Example:

<DPL>
category=Africa
addfirstcategorydate=true
</DPL>

This list will output a list of pages belonging to [[Category:Africa]], prepending each result with "DD Month YYYY: " (formatted according to your local mediawiki date display preferences).

Extension options

$wgDPL2MaxCategoryCount Maximum number of categories allowed in the SQL-query (to prevent too complex queries).

$wgDPL2AllowUnlimitedCategories Allows unlimited categories in the query. ($wgDPLMaxCategoryCount will be ignored)

$wgDPL2MinCategoryCount Minimum number of categories needed in the SQL-query for setting limits. (prevent output of a gigantiv category)

$wgDPL2MaxResultCount Maximum number of results to allow.

$wgDPL2AllowUnlimitedResults Allow unlimited results to be shown. ($wgDPLMaxResultCount will be ignored)

原文参见: DynamicPageList2

Personal tools
工具
金银币拍卖 金币拍卖预展  金银币网店 熊猫金银币 生肖金银币