Difference between revisions of "Sandbox"
(→1) |
(→1) |
||
Line 9: | Line 9: | ||
{{#dpl: | {{#dpl: | ||
|category=DPL Manual | |category=DPL Manual | ||
− | |includepage=%1 | + | |includepage=%1 |
|randomcount=10 | |randomcount=10 | ||
|format=,,°, | |format=,,°, |
Revision as of 19:49, 18 August 2009
feel free to play around
Contents
Playground
You must create valid syntax for the gallery extension if you want to use it within DPL; add debug=5 at the beginning of your statement and check what the Template Template:Infobox Country or territory dpl produces. Gero 10:34, 4 April 2008 (CEST)
1
{{#arraydefine:x|
There was a basic version of this extension some time ago. Later it was enhanced by many new features and the name was changed to DynamicPageList2. The new version was no longer downward compatible. At the same time the name of the original extension was changed to 'Intersection' (but the documentation kept talking of DynamicPageList and the tag name still was <DynamicPageList>).
Some time later another bunch of features had been added. And the name was changed back to DynamicPageList (which was thought to be 'free').
Meanwhile some new features had also been added to 'Intersection' and recently 'Intersection' requested its original name back - which caused a real lot of confusion regarding the naming.
Currently (as of June 2009) the status is as follows:
- Some wikimedia websites like wikinews use the old version. They call it 'Intersection' or 'DynamicPageList'. Its tag is <DynamicPageList> and the sources are in the mediawiki SVN under the path name 'DynamicPageList'.
- Some other websites switched to DynamicPageList2 - a version which is commonly considered to be obsolete by now. They may want to change to DPL as it is 95% downward compatible with DPL2.
- Quite a lot of websites use DPL now, i.e. the extension distributed on this website. They call it DPL or DynamicPageList. It uses the tag <dpl> and in addition offers the parser function {{#dpl: ....}}. The source is available here under Download.
There is an opinion which says that running DPL on a major public website would introduce the risk that people write queries which consume a lot of resources. And apart from there is the problem of incompatibilities between 'Intersection' and DPL.
It is time to put an end to this mess.
- A large effort was recently put into DPL to make it functionally 100% downward compatible with 'Intersection'. Missing commands were added and the semantics of some existing commands were slightly altered. For details read the chapter on DPL:Manual - Compatibility.
- A concept of functional restrictions was introduced which allows it to configure DPL with different levels of functionality. The lowest level corresponds exactly to 'Intersection' as of today.
- An advanced caching concept was introduced which makes it possible to save the result of DPL queries independent from the rest of a page. This means that this DPL cache even survives edit actions of the page containing the DPL invocation - as long as the DPL statement itself is not changed.
So, in near future there will only be one extension named DynamicPageList(DPL) which unites all previous branches.
° In the standard configuration DPL registers the <DynamicPageList> tag. This is needed to be downward compatible with extension 'Intersection'.
In the transition phase you may want to install DPL in PARALLEL to 'Intersection' for testing. DPL offers a second entry point for that purpose. Instead of require_once("DynamicPageList.php") you have to use require_once("DPLMigration.php"). DPL will then ONLY register a tag called <Intersection>
In this constellation you can change some of your existing calls of 'Intersection' (which use the <DynamicPageList> tag) to the <Intersection> tag. Once you are convinced that this produces identical results and works with equal efficiency you can change to require_once("DynamicPageList.php"). Don't forget to change the statements back to the <DynamicPageList> tag!. Of course you must also remove the require_once() for the Intersection extension. °
updaterules | define a set of rules which are executed to perform an update on selected articles (bulk update or template value editing) |
Syntax:
updaterules=
rule;
...
rule;
Where rule is one of the following:
- rules for batch update of articles
replace pattern; by replacement; before pattern; insert text; after pattern; insert text;
- rules for interactive update of articles
template template name; legend legend article name; table table format; editform form parameters; action form action; hidden value; submit submit button; commit commit button; parameter parameter name; value value; format display format; tooltip text; optional value; afterparm parameter name;
- common rules
summary edit summary text; exec value;
The first group of rules is intended for batch updates of articles. A DPL query can select a group of articles and perform updates like inserting a piece of text at a certain position or changing text portions based on regular expressions.
The second group of rules is intended for interactive form-based editing of template values.
The third group of rules is common to both other groups and controls the update process.
The updaterules feature is intended for wiki expert users only. It is recommended that articles usind this statement are 'protected':
°° The code of this extenstion uses some MySQL-specific functions which don't exist in PostgreSQL. In order to avoid patching each new version of DyanmicPageList, I suggest to run the following script on your postgres Database (from the postgres account). This simply emulates the MySQL functions.
create schema mysql; grant usage on schema mysql to public; alter user wikiuser set search_path to mediawiki, public, mysql; create or replace function mysql.concat(text, text) returns text as $function$ begin return $1 || $2; end; $function$ language plpgsql immutable strict; create or replace function mysql.if(boolean, text, text) returns text as $function$ begin if $1 then return $2; else return $3; end if; end; $function$ language plpgsql immutable strict; create or replace function mysql.ifnull(text, text) returns text as $function$ select coalesce($1, $2) as result $function$ language 'sql';
°
{{#dplreplace:text|pattern|replacement}}
°
(1) {{#dplvar:set |name1|value1|name2|value2|..|..}} (2) {{#dplvar:default|name|value}} (3) {{#dplvar: name}}
° The following example would probably be used directly on an article page, but could also be included as part of a template. Parser extensions define a specific tag (in this case <DPL>) and a corresponding end tag (</DPL>). The text between these tags is handed over to the extension module just as it is.
- Example syntax
<DPL> category = cat1|cat2 # only pages which contain a link to myPage linksto = myPage </DPL>
- Parsing procedure
Wiki markup expansion does not take place before the commands are handed over to the extension module.
- This may be useful if you want to pass wiki syntax elements to DPL2 as arguments (see the format option, for example).
- Magic words like {{PAGENAME}} or {{CURRENTDAY}} cannot be used.
- Template calls like {{{some template}}}, cannot be used as parameters.
- Parser function calls like {{#if:...|...|...}} cannot be used within arguments.
- To pass wiki syntax elements to DPL as parameters it is sometimes necessary to enforce a line break. The reason is that wiki syntax depends on line breaks. Instead, use \n or ¶ for that purpose.
- Syntax features
- Every parameter assignment (=command) has to be on a separate line.
- Lines starting with a # will be ignored (comment).
- Generally the syntax looks fairly simple and intuitive as it doesn't contain special characters (except for the two embracing tags).
- Tag case doesn't matter, so it can also be written <dpl>.
- In many cases there is no need to have macro expansion within the parameter list. Note that in the example above, the pipe character (which is used to define a logical OR between the two categories) can be written as it is. The name of the page (myPage), however, must be a hardcoded constant.
°
ordermethod | Determines what criterium (resp. criteria) is (resp. are) used to order the list. |
Syntax:
ordermethod=method1,method2,...
means ordered by method1 first, then by method2, etc. (like the ORDER BY clause in SQL)
methodN can be one of the following single tokens:
- categoryadd
- outputs list based on most recent addition to the first category (requires to include one category and one only using 'category' parameter)
- counter
- outputs list based on the number of times the page has been viewed (by ~popularity)
- size
- outputs list based on the size of the article (bytes of wiki text)
- firstedit
- outputs list based on first edit to the pages (creation)
- lastedit
- outputs list based on most recent edit to the pages
- pagetouched
- outputs list based on 'page_touched' timestamp. Read comment on
page_touched
field in Page_table to see the difference from most recent edit by an author. - pagesel
- outputs list based on the names of the reference pages which are used in the selection of a linksfrom or linksto statement. pagesel only makes sense if there is more than one page mentioned in the linksfrom or linksto condition.
- title
- outputs list sorted by article (prefix +) title
- titlewithoutnamespace
- outputs list sorted by the article name regardless of namespace — (default)
methodN can also be one of the following token combinations (see also headingmode option):
- category,firstedit
- outputs list sorted by category, then by first edit
- category,lastedit
- outputs list sorted by category, then by last edit within a category
- category,pagetouched
- outputs list sorted by category, then by pagetouched
- category,sortkey
- sortkey
- outputs list sorted by title and sortkey, requires at least one category statement
- user,firstedit
- outputs list sorted by user, then by firstedit by the user
- user,lastedit
- outputs list sorted by user, then by lastedit by the user
- none
- do not apply any ordering (except ordering by timestamp if you requested a list of revisions); this method must be used when you specify openreferences=yes.
Note: For downward compatibility reasons DPL will use 'addfirstcategory' as its default order method if called via the <dynamicPageList>
Example:
<DPL> category=Africa ordermethod=lastedit </DPL>
This list will output pages that have [[Category:Africa]] showing most recently edited articles at the top. °°|°}} {{#arraysort:x|random}} {{#arrayindex:x|0}}
3
- Cameroon
- Align=right
475,442
- Align=right
923,768
- Align=right
637,657
- Align=right
2,505,813
2
Country | Official Name | Capital | Dial Code |
---|---|---|---|
DPL Example 007 main page 1 (%COUNT%) | Template:Country dpl.default | ||
Nigunda (%COUNT%) | Republic of Nigunda | Bamitogoo | 237 |
Nigunda Test (%COUNT%) | Republic of Nigunda Test | Bamitogoo Test | 237 |
Somango (%COUNT%) | Somango Island | Aaaabququque | 224 |
Number of data = 1
No | Name | Languages | Government | Area | Population | GDP | Independence Day |
---|---|---|---|---|---|---|---|
1 | Republic of Cameroon | French,English | Republic | 183,568 sq mi | 17,795,000 | $43.196 billion | 01/10/1961 |
- Template:!
- Template:!!
- Template:!)
- Template:!-
- Template:(!
- Template:+
- Template:-
- Template:.+.pfunc
- Template:.+.pfunc.default
- Template:.cat definition
- Template:.cat make
- Template:.cat show
- Template:.class browse
- Template:.class create
- Template:.class definition
- Template:.class description
- Template:.class inheritance
- Template:.class instances
- Template:.class intro
- Template:.class menu
- Template:.class parents
- Template:.class parents 2
- Template:.class parents 3
- Template:.class parents 4
- Template:.class preload
- Template:.class properties
- Template:.class properties 2
- Template:.class properties 3
- Template:.class properties 4
- Template:.class references
- Template:.class references.ask
- Template:.class summary
- Template:.form field
- Template:.form header
- Template:.instances export wiki
- Template:.instances list html
- Template:.instances list html (form)
- Template:.list
- Template:.model class
- Template:.model extends
- Template:.model graph
- Template:.model meta graph
- Template:.model meta show
- Template:.model prop
- Template:.model show
- Template:.obj create
- Template:.obj create with form
- Template:.obj data template make
- Template:.obj get
- Template:.obj getMy
- Template:.obj getMyText
- Template:.obj getText
- Template:.obj intro
- Template:.obj intro Freshman
- Template:.obj intro Game
- Template:.obj intro Location
- Template:.obj intro Musical Instrument
- Template:.obj intro Person
- Template:.obj intro Student
- Template:.obj intro Subject
- Template:.obj intro ask
- Template:.obj intro car
- Template:.obj intro make
- Template:.obj intro top
- Template:.obj intro vehicle
- Template:.obj is a
- Template:.obj is instance of
- Template:.obj is referenced by
- Template:.obj is referenced by.ask
- Template:.obj preload
- Template:.obj preload Freshman
- Template:.obj preload Game
- Template:.obj preload Location
- Template:.obj preload Musical Instrument
- Template:.obj preload Person
- Template:.obj preload Student
- Template:.obj preload Subject
- Template:.obj preload car
- Template:.obj preload make
- Template:.obj preload vehicle
- Template:.obj set
- Template:.prop assigned by
- Template:.prop built-in
- Template:.prop create
- Template:.prop definition
- Template:.prop derived from
- Template:.prop describes
- Template:.prop intro
- Template:.prop mandatory
- Template:.prop preload
- Template:.prop refers to
- Template:.prop reverse
- Template:.prop scope
- Template:.prop unique
- Template:.report
- Template:.type built-in
- Template:=
- Template:Abc/x123
- Template:About
- Template:ActivitySummary
- Template:Activity Description
- Template:African Country
- Template:Alias Wgraph
- Template:Amp
- Template:Articles
- Template:Ask is a
- Template:Audio
- Template:Basepage subpage
- Template:Belongs to
- Template:Book
- Template:Book.published
- Template:Book.published.default
- Template:Born at
- Template:Born in
- Template:Bulk Update
- Template:Calendar/MonthStartFri
- Template:Calendar/MonthStartMon
- Template:Calendar/MonthStartSat
- Template:Calendar/MonthStartSun
- Template:Calendar/MonthStartThu
- Template:Calendar/MonthStartTue
- Template:Calendar/MonthStartWed
- Template:CalendarSingle
- Template:CalendarSingle zh-tw
- Template:Calendar anchor
- Template:Calendar link
- Template:Calendar link zh-tw
- Template:Calendar month
- Template:Calendar month zh-tw
- Template:Calendar navigation
- Template:Car
- Template:Car.list
- Template:CatTree
- Template:CatTreeSub
- Template:CategoryGallery
- Template:Category handler
- Template:Category handler/blacklist
- Template:Category handler/numbered
- Template:Category with count
- Template:Catgraph
- Template:Catlist
- Template:Catlist/zh
- Template:Catlist/zh 2
- Template:Catlist1
- Template:Catlist zh
- Template:Citation/core
- Template:Citation/identifier
- Template:Citation/make link
- Template:Citation needed
- Template:Cite book
- Template:Cite encyclopedia
- Template:Cite journal
- Template:Cite news
- Template:Cite web
- Template:Cmdref headline
- Template:Cmdref menu
- Template:Column-count
- Template:Column-width
- Template:Comma
- Template:Commons
- Template:Commons category
- Template:Continue with part
- Template:Convert
- Template:Convert/LoffAoffDbSoff
- Template:Convert/LoffAonSoff
- Template:Convert/kg
- Template:Convert/lb
- Template:Convert/numdisp
- Template:Convert/outsep
- Template:Convert/test/A
- Template:Coordinates
- Template:Country
- Template:Country.listByCapital
- Template:Country.phantom-004
- Template:Country Population
- Template:Country dpl
- Template:Create Event
- Template:Create Event zh-tw
- Template:CurrentUsers
- Template:DMCA
- Template:DPL/ImgUsed/LinkedFrom
- Template:DPL/ImgUsed/ResNum
- Template:DPL/Navi/3
- Template:DPLSNMakerSF
- Template:DPL Cache Warning
- Template:DPL Calendar code generater zh-tw
- Template:DPL Count
- Template:DPL Example 007 sub
- Template:DPL Example 007 sub 2
- Template:DPL Example 009 sub
- Template:DPL Example 010 sub
- Template:DPL Example 010 tpl
- Template:DPL Example 018 sub
- Template:DPL Example 102 piechart
- Template:DPL Example 103 barchart
- Template:DPL Page Name S/N Maker
- Template:DPL Page Name S/N Maker test
- Template:DPL parameter
- Template:DPL parameter.overview
- Template:DPL stable version
- Template:DT Article
- Template:DT Article Edit (Form)
- Template:DT Article Edit (Intro)
- Template:DT Article Edit (Intro).de
- Template:DT Article Edit (Syntax)
- Template:DT Article Edit (Syntax).de
- Template:DT Article Header
- Template:DT Article Help (Form)
- Template:DT Article Help (Intro)
- Template:DT Article Help (Intro).de
- Template:DT Article Intro (Form)
- Template:DT Article Intro (Intro)
- Template:DT Article Intro (Intro).de
- Template:DT Article Wiki (Form)
- Template:DT Article Wiki (Intro)
- Template:DT Article Wiki (Intro).de
- Template:DT Article XML (Form)
- Template:DT Article XML (Intro)
- Template:DT Article XML (Intro).de
- Template:DT Article copy
- Template:DT Article copy (Intro)
- Template:DT Article copy (Intro).de
- Template:DT Article csv (Form)
- Template:DT Article csv (Intro)
- Template:DT Article csv (Intro).de
- Template:DT Article show Refs
- Template:DT Articles list HTML
- Template:DT Articles list HTML (Form)
- Template:DT Articles list Wiki
- Template:DT Articles list Wiki (Form)
- Template:DT Articles list Wiki export.default
- Template:DT Articles list XML
- Template:DT Articles list csv
- Template:DT Articles view (Form)
- Template:DT Articles view (Intro)
- Template:DT Articles view (Intro).de
- Template:DT Category
- Template:DT Form Field
- Template:DT Form Field Link
- Template:DT Form Field Newline
- Template:DT Form Field Ref
- Template:DT Form Field Text
- Template:DT Form Header
- Template:DT Form Header.meta
- Template:DT Language
- Template:DT Link
- Template:DT Meta
- Template:DT Ref
- Template:DT Ref.report
- Template:DT Ref.report.default
- Template:DT Report create
- Template:DT Report create (Form)
- Template:DT Report create (Intro)
- Template:DT Report create (Intro).de
- Template:DT Scripts index
- Template:DT Type (Form)
- Template:DT Type create
- Template:DT Type create (Form)
- Template:DT Type create (Intro)
- Template:DT Type create (Intro).de
- Template:DT XML Field Text
- Template:DT csv
- Template:Dated maintenance category
- Template:Datetest
- Template:Datetest.dpl
- Template:DocTypes
- Template:Documentation
- Template:Documentation/docspace
- Template:Documentation/end box
- Template:Documentation/end box2
- Template:Documentation/start box
- Template:Documentation/start box2
- Template:Documentation/template page
- Template:Doi
- Template:Dpl.pfunc
- Template:Dpl.pfunc.default
- Template:Dpl.tag
- Template:Dpl.tag.default
- Template:DummyTemplate
- Template:EB1911
- Template:ECP
- Template:ECP-00055
- Template:ECP Issue
- Template:ECP number maker
- Template:Event
- Template:Event template
- Template:Event template zh-tw
- Template:Event zh-tw
- Template:Example
- Template:Export.dpl.default
- Template:ExportTransitive
- Template:ExportTransitive.img
- Template:ExportTransitive.sub
- Template:Extension DPL
- Template:Extension DPL cache
- Template:Extension DPL continue
- Template:Extension DPL scroll
- Template:FULLROOTPAGENAME
- Template:Fix
- Template:Fix/category
- Template:Flickr code generater
- Template:Fmbox
- Template:For page size test page 2
- Template:Freshman
- Template:Freshman.list
- Template:Friend
- Template:Game
- Template:Game.list
- Template:Goglemap.*.dpl
- Template:Goglemap.*.dpl.default
- Template:GoogleMap
- Template:Googlemap.*.dpl
- Template:Greenwood&Earnshaw2nd
- Template:Group
- Template:Harvard citation/core
- Template:Has document part
- Template:Has team mate
- Template:Hatnote
- Template:Hide in print
- Template:High
- Template:If pagename
- Template:Ifsubst
- Template:Index
- Template:Index.dpl1
- Template:Index.dpl2
- Template:Infobox
- Template:Infobox/row
- Template:Infobox Country or territory
- Template:Infobox Country or territory.dpl
- Template:Infobox Country or territory.edit
- Template:Infobox Country or territory dpl
- Template:Infobox Country or territory dpl2
- Template:Infobox mineral
- Template:Infobox mineral.list 1
- Template:Invalid page
- Template:Invented in
- Template:Is a
- Template:Is friend of
- Template:Is friend of.dpl
- Template:Is friend of.dpl.default
- Template:Is part of
- Template:Is to come
- Template:Issue
- Template:Jewellery
- Template:Link GA
- Template:Linkedimage
- Template:LinksTo
- Template:LinksToWithRedirect
- Template:Links 1
- Template:Links 2
- Template:Links 2.1
- Template:List articles on people by last name
- Template:Listing Redirects and Location Sub
- Template:LoadTest
- Template:LoadTestChapter
- Template:Location
- Template:Location.csv
- Template:Location.edit
- Template:Location.help
- Template:Location.intro
- Template:Location.list
- Template:Location.report.barchart inhabitants
- Template:Location.report.geoplot inhabitants
- Template:Location.report.inhabitants.data
- Template:Location.report.piechart inhabitants
- Template:Location.text
- Template:Location.view
- Template:Location.xml
- Template:Low
- Template:Magazine
- Template:Magazine.published
- Template:Magazine.published.default
- Template:Main
- Template:Musical Instrument
- Template:Musical Instrument.list
- Template:My special article lister
- Template:Nachkommen
- Template:Namespace detect
- Template:Navbox
- Template:None
- Template:Nosigr
- Template:Ns has subpages
- Template:OEtymD
- Template:Only in print
- Template:Other uses
- Template:Overline
- Template:Paar
- Template:Page size test page 1
- Template:Painter
- Template:Part of master document
- Template:Person
- Template:Person.csv
- Template:Person.edit
- Template:Person.help
- Template:Person.intro
- Template:Person.list
- Template:Person.ref.Location
- Template:Person.ref.Person
- Template:Person.text
- Template:Person.view
- Template:Placement
- Template:Plays
- Template:PoI
- Template:PoI gm
- Template:Population
- Template:Population.dpl
- Template:Population.dpl1
- Template:Population Check
- Template:Population Check1
- Template:Population Checker
- Template:Population Checker1
- Template:Pp-template
- Template:Print as one piece
- Template:Print whole text
- Template:Publication
- Template:Publication.default
- Template:Px
- Template:RP.dpl.default
- Template:Redirect
- Template:Redirs
- Template:Reflist
- Template:Sandbox
- Template:Sandbox2
- Template:Schnittstellen Übersicht Mini
- Template:Schnittstellen Übersicht Mini dpl
- Template:See Wgraph
- Template:See also
- Template:Set Template Parameter
- Template:Sfn
- Template:Short
- Template:ShortLink
- Template:ShortLink/Examples
- Template:ShortLink/Examples/List
- Template:ShortURL
- Template:ShortURL/Examples
- Template:ShortURL/Examples/List
- Template:ShortenString
- Template:Siblings
- Template:Side box
- Template:Silica minerals
- Template:Sister
- Template:Slow
- Template:Some Template
- Template:Some Template.dpl
- Template:Some Template.dpl2
- Template:Some Template.dpl3
- Template:Sortable Tables
- Template:Step.dpl
- Template:Str left
- Template:Student
- Template:Student.list
- Template:Studies
- Template:Studies in
- Template:Subject
- Template:Subject.list
- Template:Symbols
- Template:TOCright
- Template:Teaser
- Template:TempTree
- Template:Template.edit
- Template:Template other
- Template:Templink
- Template:Test
- Template:Test2
- Template:Test Amp3/Template
- Template:Test Amp3/Template2
- Template:Test Country Population
- Template:Test get chapter
- Template:Test subgoal
- Template:Tl
- Template:Tmp2
- Template:Todo
- Template:Todo.dpl
- Template:Todo.pri
- Template:Todo2
- Template:Topic
- Template:Topic group
- Template:Topic group.dpl
- Template:Transclude
- Template:Translation
- Template:Translation.table
- Template:Trip
- Template:Trip.csv
- Template:Trip.edit
- Template:Trip.help
- Template:Trip.intro
- Template:Trip.ref.Location
- Template:Trip.ref.Person
- Template:Trip.text
- Template:Trip.view
- Template:Type?.help
- Template:Type?.intro
- Template:Type?.text
- Template:Type Manual
- Template:Type Manual.overview
- Template:Type Test
- Template:UsageCount
- Template:Use dmy dates
- Template:UsesTest
- Template:Vehicle
%TOTALPAGES%
{{#dpl: category=African_Union_member_states¦Cities|resultsheader=%PAGES%|noresultsheader=none|mode=userformat
9
{{#dpl: category=African_Union_member_states¦Cities|resultsheader=%TOTALPAGES%|noresultsheader=none|mode=userformat
9
1 3.2.1
good morning!