Difference between revisions of "TemplatedPageList"

From Wiki4Intranet
Jump to: navigation, search
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
This is Yet Another Page Listing extension. It is similar to DynamicPageList & company ([[mediawikiwiki:Extension:DynamicPageList (Wikimedia)|Intersection / Wikimedia's DPL]], [[mediawikiwiki:Extension:DynamicPageList (third-party)|3rd party's DPL]], [[mediawikiwiki:Extension:SubPageList|SubPageList]], 2, etc), but the code is simpler and the functionality is more advanced. Initially, it was just an improved [[mediawikiwiki:Extension:SubPageList2|SubPageList2]].
+
{{Extension4info
 +
|name=TemplatedPageList
 +
|description ru=Наше расширение для вывода списков вики-страниц. Похоже на DPL, поддерживает вывод по шаблону и имеет интерфейс на спецстранице.
 +
|description en=Page listing extension. Similar, but better in some ways than DPL & company. Supports template output and special page UI.
 +
|authors=[[User:VitaliyFilippov]]
 +
|created=2009-11-09
 +
|version=2012-12-12
 +
|included=2009-11-09
 +
|status=our
 +
|useful=likely
 +
}}
 +
{{ExtensionFromInfo|lang=en|name=TemplatedPageList}}
 +
 
 +
== Features ==
 +
 
 +
This is Yet Another Page Listing extension. It is similar to DynamicPageList & company ([[mediawikiwiki:Extension:DynamicPageList (Wikimedia)|Intersection / Wikimedia’s DPL]], [[mediawikiwiki:Extension:DynamicPageList (third-party)|3rd party’s DPL]], [[mediawikiwiki:Extension:SubPageList|SubPageList]], [[mediawikiwiki:Extension:SubPageList2|SubPageList2]], [[mediawikiwiki:Extension:SubPageList2|SubPageList3]], etc), but the code is simpler and the functionality is more advanced.
 +
 
 +
Initially, it was just an improved [[mediawikiwiki:Extension:SubPageList2|SubPageList2]]. Then it survived several feature additions and refactorings (previous authors probably were C-coders and big lovers of rounding integers (<tt>round(intval($options['count']))</tt>)).
  
 
Features:
 
Features:
 
* (Main feature) '''&lt;subpagelist&gt;''' tag produces a simple or ''templated'' list of pages selected by dynamic conditions.
 
* (Main feature) '''&lt;subpagelist&gt;''' tag produces a simple or ''templated'' list of pages selected by dynamic conditions.
 +
* Special page with form interface to &lt;subpagelist&gt; ([[Special:TemplatedPageList]])
 
* <nowiki>{{#getsection|Title|section number}}</nowiki> parser function for extracting page sections by number.
 
* <nowiki>{{#getsection|Title|section number}}</nowiki> parser function for extracting page sections by number.
 
* Automatic AJAX display of subpages everywhere.
 
* Automatic AJAX display of subpages everywhere.
  
Details:
+
TODO:
* Author: Vitaliy Filippov, 2009+
+
* Support «materialization» of lists in the DB, enable caching and support correct refreshing of parser cache by saving dependencies into database.
* License: GPLv2 or higher
+
* Code is part of [[MediaWiki4Intranet]] and lives on [http://code.google.com/p/mediawiki4intranet/source/browse/?name=mw4install#hg%2Fextensions%2FSubPageList2 Google Code]
+
  
 
== Automatic subpage listing ==
 
== Automatic subpage listing ==
  
SubPageList can add a simple link to each page, and when clicked, this link displays list of all subpages of current page.
+
'''TemplatedPageList''' can add a simple link to each page, and when clicked, this link displays list of all subpages of current page.
  
 
<tt>$egSubpagelistAjaxNamespaces = array(NS_MAIN => true);</tt> setting enables this on namespaces specified.
 
<tt>$egSubpagelistAjaxNamespaces = array(NS_MAIN => true);</tt> setting enables this on namespaces specified.
  
 
<tt>$egSubpagelistAjaxDisableRE = "regexp";</tt> is a regexp disables this on pages whose title match it.
 
<tt>$egSubpagelistAjaxDisableRE = "regexp";</tt> is a regexp disables this on pages whose title match it.
 +
 +
== <nowiki>{{#getsection}}</nowiki> ==
 +
 +
If you want to include first section of page, use the following instruction:
 +
 +
<pre><includeonly>{{#getsection:0|{{:{{FULLPAGENAME}}|here|you|can|pass|parameters}}}}</includeonly></pre>
  
 
== &lt;subpagelist&gt; syntax ==
 
== &lt;subpagelist&gt; syntax ==
  
Syntax is backwards compatible with [[mediawikiwiki:Extension:DynamicPageList_(Wikimedia)|Wikimedia's DynamicPageList]] syntax,
+
Syntax is backwards compatible with [[mediawikiwiki:Extension:DynamicPageList_(Wikimedia)|Wikimedia’s DynamicPageList]] syntax,
except for 'firstcategorydate' related stuff. The text inside <tt>&lt;subpagelist></tt>
+
except for 'firstcategorydate' related stuff. The text inside <tt>&lt;subpagelist&gt;</tt>
 
is preprocessed, so you can use templates, magic words and parser functions
 
is preprocessed, so you can use templates, magic words and parser functions
 
inside it. Options are specified one per line.
 
inside it. Options are specified one per line.
  
=== Open tag ===
+
=== Open the tag or parser function ===
  
'''<tt>&lt;subpagelist&gt;</tt>''' (you can also use &lt;DynamicPageList&gt; or &lt;subpages&gt; for compatibility)
+
'''<tt>&lt;templatedpagelist&gt;</tt>''' (you can also use one of &lt;subpagelist&gt;, &lt;DynamicPageList&gt; or &lt;subpages&gt; for compatibility)
 +
 
 +
or
 +
 
 +
'''<tt><nowiki>{{#templatedpagelist:</nowiki></tt>'''
  
 
=== Page selection ===
 
=== Page selection ===
  
; namespace = Main|Talk|...: Restrict list to some namespaces
+
; namespace = Main|Talk|: Restrict list to some namespaces
; category = A|B|C<br /> category = D|E: Restrict page list to pages which are in one of these categories. This option may be specified multiple times, following occurrences will be appended as a conjunction, i.e., the resulting expression will be (A or B or C) & (D or E). This is compatible with Wikimedia's DynamicPageList syntax, but allows more complex queries.
+
; category = A|B|C<br /> category = D|E: Restrict page list to pages which are in one of these categories. This option may be specified multiple times, following occurrences will be appended as a conjunction, i.e., the resulting expression will be (A or B or C) & (D or E). This is compatible with Wikimedia’s DynamicPageList syntax, but allows more complex queries.
; notcategory = A: Exclude pages which are in category A
+
; subcategory = F|G: Like previous, but recursively including all subcategories of F and G.
; parent = P: Restrict listing to subpages of P
+
; notcategory = A: Exclude pages which are in category A.
 +
; notsubcategory = B: Exclude pages from category B and all its subcategories.
 +
; parent = P: Restrict listing to subpages of P.
 +
; prefix = P: Restrict listing to pages whose title starts with P. I.e. '''<tt>parent=P</tt>''' is equivalent to '''<tt>prefix=P/</tt>'''.
 
; level = L or MIN..MAX: Set wanted subpage nesting levels (i.e. number of '/' in title) it must be equal to L or be within MIN..MAX.
 
; level = L or MIN..MAX: Set wanted subpage nesting levels (i.e. number of '/' in title) it must be equal to L or be within MIN..MAX.
 
; deepness = D or MIN..MAX: Set wanted subpage nesting levels, relative to parent.
 
; deepness = D or MIN..MAX: Set wanted subpage nesting levels, relative to parent.
; ignore = L1|L2|...: Ignore pages which match L1 or L2 or ... LIKE patterns:
+
; ignore = L1|L2|: Ignore pages which match L1 or L2 or LIKE patterns:
:* '\_' and ' ' match single space
+
:* '\_' and ' ' match single space.
:* '_' matches any single character
+
:* '_' matches any single character.
:* '%' matches any substring
+
:* '%' matches any substring.
:* '\%' matches single '%' character
+
:* '\%' matches single '%' character.
; redirect = yes|no: restring listing to redirect or non-redirect pages
+
; redirect = yes|no: restring listing to redirect or non-redirect pages.
  
 
=== Ordering ===
 
=== Ordering ===
  
;order|ordermethod = Y1 [asc|desc],Y2 [asc|desc],...: Sort pages by Y1,Y2,..., asc|desc can be specified right after Yi, each Yi is one of:
+
;order|ordermethod = Y1 [asc|desc],Y2 [asc|desc],: Sort pages by Y1,Y2,, asc|desc can be specified right after Yi, each Yi is one of:
:* title
+
:* title|fullpagename
:* titlewithoutnamespace
+
:* titlewithoutnamespace|pagename
 
:* lastedit
 
:* lastedit
 
:* user
 
:* user
Line 61: Line 90:
 
=== Output ===
 
=== Output ===
  
 +
;showtotal = yes|no: Show (or not) total count of found pages. Don't show by default.
 +
;output = simple|column|template: Select output method.
 +
:* Simple is just a bullet-list with page titles and links.
 +
:* Column is a 3-column grouped view, just as on MediaWiki category pages.
 +
:* Templated view uses template for display. See 'template' option.
 
;template = X: Use template:X for output. The template will be preprocessed just like when included into listed article. I.e. all standard MediaWiki magic variables (<nowiki>{{PAGENAME}} {{REVISIONDAY}}</nowiki> etc) will generate values corresponding to listed articles. Additionally, the following parameters are passed to this template:
 
;template = X: Use template:X for output. The template will be preprocessed just like when included into listed article. I.e. all standard MediaWiki magic variables (<nowiki>{{PAGENAME}} {{REVISIONDAY}}</nowiki> etc) will generate values corresponding to listed articles. Additionally, the following parameters are passed to this template:
:; <nowiki>{{{</nowiki>index}}}     : list index, beginning at 0
+
:; <nowiki>{{{</nowiki>index}}} : list index, beginning at 0
:; <nowiki>{{{</nowiki>number}}}   : list index, beginning at 1
+
:; <nowiki>{{{</nowiki>number}}} : list index, beginning at 1
:; <nowiki>{{{</nowiki>odd}}}       : is <nowiki>{{{</nowiki>number}}} odd? (1 or 0)
+
:; <nowiki>{{{</nowiki>odd}}} : is <nowiki>{{{</nowiki>number}}} odd? (1 or 0)
:; <nowiki>{{{</nowiki>ns_N}}}     : N is namespace index, value is 1
+
:; <nowiki>{{{</nowiki>ns_N}}} : N is namespace index, value is 1
:; <nowiki>{{{</nowiki>title}}}     : full title
+
:; <nowiki>{{{</nowiki>title}}} : full title
 
:; <nowiki>{{{</nowiki>title_rel}}} : title relative to parent specified in options
 
:; <nowiki>{{{</nowiki>title_rel}}} : title relative to parent specified in options
 
; suppresserrors|noerrors|silent = true: Suppress errors.
 
; suppresserrors|noerrors|silent = true: Suppress errors.
  
=== Close tag ===
+
=== Close tag / PF ===
 +
 
 +
'''<tt>&lt;/templatedpagelist&gt;</tt>'''
 +
 
 +
or
 +
 
 +
'''<tt><nowiki>}}</nowiki></tt>'''
 +
 
 +
== Installation ==
 +
 
 +
You just need to add the following to LocalSettings.php:
  
'''<tt>&lt;/subpagelist&gt;</tt>'''
+
<code-php>
 +
require_once "$IP/extensions/TemplatedPageList/TemplatedPageList.php";
 +
</code-php>

Latest revision as of 17:34, 17 April 2013

TemplatedPageList is a MediaWiki extension.

Status for Mediawiki4Intranet distribution:

  • Inclusion date: 2009-11-09
  • Included version: newest available
  • Improvement status: Created by MediaWiki4Intranet project

Features

This is Yet Another Page Listing extension. It is similar to DynamicPageList & company (Intersection / Wikimedia’s DPL, 3rd party’s DPL, SubPageList, SubPageList2, SubPageList3, etc), but the code is simpler and the functionality is more advanced.

Initially, it was just an improved SubPageList2. Then it survived several feature additions and refactorings (previous authors probably were C-coders and big lovers of rounding integers (round(intval($options['count'])))).

Features:

  • (Main feature) <subpagelist> tag produces a simple or templated list of pages selected by dynamic conditions.
  • Special page with form interface to <subpagelist> (Special:TemplatedPageList)
  • {{#getsection|Title|section number}} parser function for extracting page sections by number.
  • Automatic AJAX display of subpages everywhere.

TODO:

  • Support «materialization» of lists in the DB, enable caching and support correct refreshing of parser cache by saving dependencies into database.

Automatic subpage listing

TemplatedPageList can add a simple link to each page, and when clicked, this link displays list of all subpages of current page.

$egSubpagelistAjaxNamespaces = array(NS_MAIN => true); setting enables this on namespaces specified.

$egSubpagelistAjaxDisableRE = "regexp"; is a regexp disables this on pages whose title match it.

{{#getsection}}

If you want to include first section of page, use the following instruction:

<includeonly>{{#getsection:0|{{:{{FULLPAGENAME}}|here|you|can|pass|parameters}}}}</includeonly>

<subpagelist> syntax

Syntax is backwards compatible with Wikimedia’s DynamicPageList syntax, except for 'firstcategorydate' related stuff. The text inside <subpagelist> is preprocessed, so you can use templates, magic words and parser functions inside it. Options are specified one per line.

Open the tag or parser function

<templatedpagelist> (you can also use one of <subpagelist>, <DynamicPageList> or <subpages> for compatibility)

or

{{#templatedpagelist:

Page selection

namespace = Main|Talk|…
Restrict list to some namespaces
category = A|B|C
category = D|E
Restrict page list to pages which are in one of these categories. This option may be specified multiple times, following occurrences will be appended as a conjunction, i.e., the resulting expression will be (A or B or C) & (D or E). This is compatible with Wikimedia’s DynamicPageList syntax, but allows more complex queries.
subcategory = F|G
Like previous, but recursively including all subcategories of F and G.
notcategory = A
Exclude pages which are in category A.
notsubcategory = B
Exclude pages from category B and all its subcategories.
parent = P
Restrict listing to subpages of P.
prefix = P
Restrict listing to pages whose title starts with P. I.e. parent=P is equivalent to prefix=P/.
level = L or MIN..MAX
Set wanted subpage nesting levels (i.e. number of '/' in title) it must be equal to L or be within MIN..MAX.
deepness = D or MIN..MAX
Set wanted subpage nesting levels, relative to parent.
ignore = L1|L2|…
Ignore pages which match L1 or L2 or … LIKE patterns:
  • '\_' and ' ' match single space.
  • '_' matches any single character.
  • '%' matches any substring.
  • '\%' matches single '%' character.
redirect = yes|no
restring listing to redirect or non-redirect pages.

Ordering

order|ordermethod = Y1 [asc|desc],Y2 [asc|desc],…
Sort pages by Y1,Y2,…, asc|desc can be specified right after Yi, each Yi is one of:
  • title|fullpagename
  • titlewithoutnamespace|pagename
  • lastedit
  • user
  • creation|firstedit
  • length|size
  • popularity|pagecounter
order = ASC or DESC
Ascending or descending sort order for all Yi (compatibility)
count|limit = N
Show at most N pages
offset = M
Skip first M pages

Output

showtotal = yes|no
Show (or not) total count of found pages. Don't show by default.
output = simple|column|template
Select output method.
  • Simple is just a bullet-list with page titles and links.
  • Column is a 3-column grouped view, just as on MediaWiki category pages.
  • Templated view uses template for display. See 'template' option.
template = X
Use template:X for output. The template will be preprocessed just like when included into listed article. I.e. all standard MediaWiki magic variables ({{PAGENAME}} {{REVISIONDAY}} etc) will generate values corresponding to listed articles. Additionally, the following parameters are passed to this template:
{{{index}}} 
list index, beginning at 0
{{{number}}} 
list index, beginning at 1
{{{odd}}} 
is {{{number}}} odd? (1 or 0)
{{{ns_N}}} 
N is namespace index, value is 1
{{{title}}} 
full title
{{{title_rel}}} 
title relative to parent specified in options
suppresserrors|noerrors|silent = true
Suppress errors.

Close tag / PF

</templatedpagelist>

or

}}

Installation

You just need to add the following to LocalSettings.php:

require_once "$IP/extensions/TemplatedPageList/TemplatedPageList.php";