Difference between revisions of "DPL Example 014"
(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...) |
|||
Line 5: | Line 5: | ||
<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|<br/>}} | ||
</nowiki></pre> | </nowiki></pre> | ||
Line 16: | Line 16: | ||
----------------------------------- | ----------------------------------- | ||
DPL produces the following wikitext as output (which is fed into #arraydefine ..): | DPL produces the following wikitext as output (which is fed into #arraydefine ..): | ||
+ | {{#replace: | ||
{{#dpl: | {{#dpl: | ||
|debug=5 | |debug=5 | ||
Line 21: | Line 22: | ||
|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: | ||
Line 32: | Line 37: | ||
|format=,%TITLE%,§, | |format=,%TITLE%,§, | ||
}}|§}} | }}|§}} | ||
− | {{#arrayprint:x|<br/>}} | + | {{#arrayprint:x|<br/>}} |
Revision as of 12:59, 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 the paragraph symbol).
See [1] to see what you can do with the ArrayExternsion ...
{{#arraydefine:x|{{#replace: {{#dpl: |titlematch=B% |count=10 |format=,%TITLE%,§, }}|§}}|/§$/|}} {{#arrayprint:x|<br/>}}
DPL produces the following wikitext as output (which is fed into #arraydefine ..): {{#replace:
{{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| 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|
}}