Tipwiki:Extentions

From the archives of TiPWiki, the unofficial Duke TIP Wiki
Jump to: navigation, search

Dynamic Page List 2

Improvements und Changes

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!


Using DynamicPageList

The Dynamic Page List (DPL) is a . To use it, 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 commas '|' 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=1st category name|2nd category name|3rd category name|...

Example:

<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=category name

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=1st namespaceid or name|2nd namespaceid or name|3rd namespaceid or name|...

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=modename

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
  • 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 <ol>...</ol> list.

order

Purpose:

Controls the sort direction of the list.

Example:

order=orderdirection

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=number of results

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=method

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=criteria

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)


WikiWebLog

To use WikiWebLog, include the tag <blog> to open the protected section. The protected section is then closed with </blog>

From there, multiple options are available:

    * title - Set the blog entry title
    * author - Set the author's name, currently ignored
    * date - Set the date of the entry
    * link - A URL the entry should link to 

Additionally, if title is empty, there is an additional option:

    * limit - Set a limit on displayed entries 

List Backlinks

Description

This extension is a modification of Fxparlant's User:Fxparlant/Blog|Blog extension. When called, it outputs a list of pages within a defined category that link to the current page.
It will only work with MediaWiki 1.5. If you're using an earlier version, the link above is probably what you're looking for. I had to change Fxparlant's version in order to get it working on my 1.5 install, because the DB scheme has changed. In the process, I used some code from the DynamicPageList extension.


BE WARNED: I am a complete newbie to MediaWiki, to PHP and to MySQL. I therefore cannot vouch for the effectiveness or safety of this code beyond saying that it works for me.


Note: If you can suggest any improvements to this code, they would be greatly appreciated.


Usage

Like Fxparlant's original extension, you will call this from somewhere in your code using the following:

<blink>cat=YourCategory</blink>

This will display a list of pages in YourCategory that link to the current page. Like Fxparlant's code, you can also specify a page that is not the current page:

<blink>page=Frantz_Fanon;cat=Sources</blink>

This will return a list of articles in the "Sources" category that link to Frantz Fanon (presumably as their author).

</DPL>