Difference between revisions of "DPL Example 014"

From FollowTheScore
Jump to: navigation, search
(New page: We load the result of a DPL query into an array and print that array using a different separator. The trick is to use a special separator in the format statement of your DPL query (in this...)
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
We load the result of a DPL query into an array and print that array using a different separator.
 
We load the result of a DPL query into an array and print that array using a different separator.
The trick is to use a special separator in the format statement of your DPL query (in this example we use the paragraph symbol).
+
The trick is to use a special separator in the format statement of your DPL query (in this example we use '''°''', i.e. the degree symbol).
  
See [http://www.mediawiki.org/wiki/Extension:ArrayExtension] to see what you can do with the '''ArrayExternsion''' ...
+
See [http://www.mediawiki.org/wiki/Extension:ArrayExtension] to learn what you can do with the '''ArrayExternsion''' ...
  
 
<pre><nowiki>
 
<pre><nowiki>
{{#arraydefine:x|
+
{{#arraydefine:x|{{#replace:
 
{{#dpl:
 
{{#dpl:
 
  |titlematch=B%
 
  |titlematch=B%
 
  |count=10
 
  |count=10
  |format=,%TITLE%,§,
+
  |format=,%TITLE%,°,
}}|§}}
+
}}|/°$/|}}|°}}
{{#arrayprint:x|<br/>}}
+
{{#arrayprint:x|---}}
 
</nowiki></pre>
 
</nowiki></pre>
  
Line 20: Line 20:
 
  |titlematch=B%
 
  |titlematch=B%
 
  |count=10
 
  |count=10
  |format=,%TITLE%,§,
+
  |format=,%TITLE%,°,
}}|§}}
+
}}
  
 +
Note that the array definition contains a final separator symbol which creates an empty array element at the end of the array.
 +
We can throw that element away using #arrayslice or we delete the final separation character using #replace.
 +
 +
 
 
------------------------------------
 
------------------------------------
 
So the following output is produced:
 
So the following output is produced:
  
{{#arraydefine:x|
+
{{#arraydefine:x|{{#replace:
 
{{#dpl:
 
{{#dpl:
 
  |titlematch=B%
 
  |titlematch=B%
 
  |count=10
 
  |count=10
  |format=,%TITLE%,§,
+
  |format=,%TITLE%,°,
}}|§}}
+
}}|/°$/|}}|°}}
{{#arrayprint:x|<br/>}}
+
{{#arrayprint:x|---}}

Latest revision as of 13:12, 10 May 2009

We load the result of a DPL query into an array and print that array using a different separator. The trick is to use a special separator in the format statement of your DPL query (in this example we use °, i.e. the degree symbol).

See [1] to learn what you can do with the ArrayExternsion ...

{{#arraydefine:x|{{#replace:
{{#dpl:
 |titlematch=B%
 |count=10
 |format=,%TITLE%,°,
}}|/°$/|}}|°}}
{{#arrayprint:x|---}}

DPL produces the following wikitext as output (which is fed into #arraydefine ..):

{{Extension DPL}}Bruxelles city°Bug Apo°Boolean°Bug Apo 3°Bug'Apo 4°Berlin°Bob Jones Out Sick°Bug SQL 1064°Berliner Mauer°Berlin Wall°

Note that the array definition contains a final separator symbol which creates an empty array element at the end of the array. We can throw that element away using #arrayslice or we delete the final separation character using #replace.



So the following output is produced:

{{#arraydefine:x|{{#replace: Bruxelles city°Bug Apo°Boolean°Bug Apo 3°Bug'Apo 4°Berlin°Bob Jones Out Sick°Bug SQL 1064°Berliner Mauer°Berlin Wall°|/°$/|}}|°}} {{#arrayprint:x|---}}