DPL talk:Manual - DPL parameters: Controlling output format

From FollowTheScore
Revision as of 11:35, 11 August 2014 by Ianb1469 (talk | contribs) (Inject CSS into table headings of table)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Actual output examples

This page could do with actual output examples instead of showing just code... Also, how do I get a template's field value to show up as specified in the template (with wiki markup)? -Eep² 12:22, 26 July 2007 (CEST)

I agree. But I would not like to have all the examples within the manaul page. We should take the way 'selfhtml' went. So there should be a new Category called 'DPL Manual Demo' or something like that. Each Demo sample should be memeber of that category. It should have a back ling to the manual. And of course the manual should have a link to the exampe ;-). Maybe one could even find a generic way to show the sourcecode of the example - this would be quite helpful.
Gero 15:03, 26 July 2007 (CEST)

getting wiki markup

I do not quite understand the question from above. If you use the template substitution mechanism parameters will be expanded before they are passed to the "surrogate" template. If you use the {templatename}:xx syntax a primitive scanner will identify the position of the template call in the wiki text of the caller and it will return the wikitext it finds between the parameter name and the next '|'. This is enough in many cases, but does not work correctly if the parameter value itself contains another template invocation. Note: the parser was improved in 1.2.9 and now respects wiki syntax conventions.

Gero 15:09, 26 July 2007 (CEST)
Thanks but I'm not sure how this works. How can I get the wiki markup/syntax to be outputted in the list/table? How would I change the code below (see #resultsfooter bug as parser function)? -Eep² 10:36, 27 July 2007 (CEST)
See http://www.tnlc.com/wiki/index.php?title=Comparison_table for what I'm trying to do. Template:game doesn't use templates but does have wiki markkup which I would like each field that appears in the comparison table to contain (that, in this case, links to the category of the same name). How do I do this? Obviously, if I pulled in this game template's fields, they would also categorize the comparison table into every category too, so I just need a way to add category links to each field in the DPL output (preferably also being able to use a template if desired). Is this possible?
I see there is a %SECTION% parameter for secseparators but I don't see a %FIELD% for use with templates. Can this be added that will pull in the template field's contents and allow it to be wiki-formatted ([[%FIELD%]], [[:Category:%FIELD%]], etc) and, if specified, have escapelinks (or a relevant parameter like parse) to either strip the wiki markup or show (parse/whatever) it as it would be if the template field was in a normal wiki article (with wiki links, category designations, etc). If all of this is already possible with DPL, please tell me how. -Eep² 08:04, 27 July 2007 (CEST)
I don't understand what you mean by "{templatename}:xx syntax"--I thought that was only for the includepage parameter? Why doesn't it work correctly if another template inclusion is in the parameter value?
Also, is there a resultsfooter parameter? I'd like to create a "totals" row below the table of how many games there are but resolutsheader only seems to be able to appear above the table.
Lastly, the edit page has a lot of "undefined" text that appears, trying to render non-existent edit buttons, probably. -Eep² 15:23, 26 July 2007 (CEST)
I'm having this problem ever since I got SimpleForms to work. Do you know how you fixed it? -Eep² 12:04, 17 August 2007 (CEST)
Disable mootools. Gero 12:13, 17 August 2007 (CEST)
Unfortunately, doing that disables most of SimpleForms' functionality (like listing category articles in the test example on User:Eep²). :/ -Eep² 12:46, 17 August 2007 (CEST)

resultsfooter bug as parser function

Thanks for adding this, but I think I found a bug. On http://www.tnlc.com/wiki/index.php?title=Comparison_table I have these DPL declarations for tables:

<dpl>
  category=Games
  includepage={game}:year,{game}:genre,{game}:publisher,{game}:developer,{game}:engine,{game}:character
  mode=userformat
  ordermethod=title
  listseparators=\n{|order cellpadding=0 cellspacing=0 class=sortable border style="border: 1px black; font-family: Tahoma; font-size: 8pt"\n !Game\n !Year\n !Genre\n !Publisher\n !Developer\n !Engine\n !Character,\n|-\n|[[%PAGE%]],,\n|}
  secseparators=\n|
  resultsfooter=Total games: %PAGES%
</dpl>

{{#dpl:
category=Games
|includepage={game}:year,{game}:genre,{game}:publisher,{game}:developer,{game}:engine,{game}:character
|mode=userformat
|ordermethod=title
|listseparators=\n{¦cellpadding=0 cellspacing=0 border class=sortable style="border: 1px black; font-family: Tahoma; font-size: 8pt"\n!{{cat|Games|Game}}\n !{{cat|Years|Year}} !!{{cat|Genres|Genre}} !!{{cat|Companies|Publisher}} !!{{cat|Companies|Developer}} !!{{cat|Engines|Engine}} !!{{cat|Player characters|Character}},\n¦-\n¦[[%PAGE%]],,¦}
|secseparators=\n¦
|uses=Template:game
|resultsfooter=Total games: %PAGES%
}}

The parser function version displays the footer (plus a }) inside the last table cell while the parser extension version displays it correctly. -Eep² 10:28, 27 July 2007 (CEST)

That is strange. Can you try adding \n as the first two characters in the footer? Gero 10:38, 27 July 2007 (CEST)
Doing that results in a new line under the } and before "Total games: %PAGES%"--but the footer is still inside the last table cell (which should contain "Lara Croft", the name of the game's player character that appears in the DPL parser extension table version above. -Eep² 10:43, 27 July 2007 (CEST)
Your table definition starts each item with a |-; try instead to put an initial |- at the end of the first part of listseparators (table headline) and then use the THIRD parameter to END each line with |-. Gero 10:59, 27 July 2007 (CEST)
I don't understand what you mean. Can you edit the listseparators line here as to how you mean?
|listseparators=\n{¦cellpadding=0 cellspacing=0 border class=sortable style="border: 1px black; font-family: Tahoma; font-size: 8pt"\n!{{cat|Games|Game}}\n !{{cat|Years|Year}} !!{{cat|Genres|Genre}} !!{{cat|Companies|Publisher}} !!{{cat|Companies|Developer}} !!{{cat|Engines|Engine}} !!{{cat|Player characters|Character}},\n¦-\n¦[[%PAGE%]],,¦}
-Eep² 11:05, 27 July 2007 (CEST)
see my modifications below. The main point, however, is probably that the LAST argument should start with \n. Maybe you change only this first and try if it works. You might also want to use the debugging trick I described in the FAQ document..
|listseparators=\n{¦cellpadding=0 cellspacing=0 border class=sortable style="border: 1px black; font-family: Tahoma; font-size: 8pt"\n!{{cat|Games|Game}}\n !{{cat|Years|Year}} !!{{cat|Genres|Genre}} !!{{cat|Companies|Publisher}} !!{{cat|Companies|Developer}} !!{{cat|Engines|Engine}} !!{{cat|Player characters|Character}}\n¦-,\n¦[[%PAGE%]],\n¦-\n,\n¦}

Gero 14:24, 27 July 2007 (CEST)

OK, this works, but I'm not sure why it's necessary since the parser extension works fine the other way. Ah well. Now, is there any way to add wiki markup/syntax to each cell? I'd like each cell to link to the category of the same name, for example. -Eep² 21:50, 27 July 2007 (CEST)
Use surrogate templates, e.g. include={game}.dpl and do whatever you want in "Template:game.dpl". It receives all the parameters of the original Template:game plus %PAGE% and %TITLE%. This gives you more flexibility than the 'include={game}:paramNrOrName approach. Use the 'debug trick' from the FAQ if the result table looks weird. Gero 23:44, 27 July 2007 (CEST)
I'm not sure what you mean by a surrogate template. I'd rather not have to create a different template that has the exact same values as the normal/regular template... Can't DPL just pull in the fields from the normal/regular template with an option to not strip their wiki markup (and also have a way to add wiki/HTML markup in a cell parameter, perhaps--or within listseparators like the table headers can)? -Eep² 05:22, 28 July 2007 (CEST)
NO. Go and create the different template. Gero 08:45, 28 July 2007 (CEST)
OK, but I don't see why a special DPL template is even necessary since it also includes wiki markup and duplicates the fields in the non-DPL template. Is it that hard to just pull out the fields from the non-DPL template and allow specialized wiki markup within the DPL parser function/extension as is done with formatting for lists, the table header, and even the table's first row's cell! I just don't get it...you even also allow special cell secseparators so why not a cell (or a general field) parameter for template parameters (+ a %FIELD% special/magic word--whatever, to pull in the current field--or maybe %TPARAM% for "template parameter") that allows wiki markup too? Just seems having to make another template is unnecessary and means having to maintain 2 templates instead of just one...plus the DPL function to designate the template fields (and the headers)... Ideally, a single template should be all that is necessary for DPL to pull in the table header/cell fields. Something like this:
{{#dpl:
category=Games
|includepage={game}:year,{game}:genre,{game}:publisher,{game}:developer,{game}:engine,{game}:character
|ordermethod=title
|listseparators=\n{¦cellpadding=0 cellspacing=0 border class=sortable style="border: 1px black; font-family: Tahoma; font-size: 8pt"\n!{{cat|Games|Game}}\n !{{cat|Years|Year}} !!{{cat|Genres|Genre}} !!{{cat|Companies|Publisher}} !!{{cat|Companies|Developer}} !!{{cat|Engines|Engine}} !!{{cat|Player characters|Character}}\n¦-,\n¦[[%PAGE%]],\n¦-\n,\n¦}
|secseparators= ¦¦
|field=[[:Category:%FIELD%|]]
|uses=Template:game
|resultsfooter='''Total games: %PAGES%'''
}}

Or the %FIELD% could be in listseparators:

|listseparators=\n{¦cellpadding=0 cellspacing=0 border class=sortable style="border: 1px black; font-family: Tahoma; font-size: 8pt"\n!{{cat|Games|Game}}\n !{{cat|Years|Year}} !!{{cat|Genres|Genre}} !!{{cat|Companies|Publisher}} !!{{cat|Companies|Developer}} !!{{cat|Engines|Engine}} !!{{cat|Player characters|Character}}\n¦-,\n¦[[%PAGE%]],\n¦-\n[[%FIELD%]],\n¦}

Or, more specifically, also allow pulling in the exact template fields for specific markup:

|listseparators=\n{¦cellpadding=0 cellspacing=0 border class=sortable style="border: 1px black; font-family: Tahoma; font-size: 8pt"\n!{{cat|Games|Game}}\n !{{cat|Years|Year}} !!{{cat|Genres|Genre}} !!{{cat|Companies|Publisher}} !!{{cat|Companies|Developer}} !!{{cat|Engines|Engine}} !!{{cat|Player characters|Character}}\n¦-,\n¦[[%PAGE%]] || [[{{{year}}}]] || [[:Category:{{{genre}}}]] || [[{{{publisher}}}|Different publisher]] || [[Wikipedia:{{{developer}}}|]] || [[{{{engine}}}]] || {{{character}}}\n¦-\n,\n¦}

Although, it might have to be {template}:field instead of {{{field}}} since multiple templates can be used which may have the same parameter/field names. -Eep²

I can't get this DPL template to work with the above code (substituting this for the includepage line):

|includepage={game}.dpl:year,{game}.dpl:genre,{game}.dpl:publisher,{game}.dpl:developer,{game}.dpl:engine,{game}.dpl:character

And I tried this too:

|includepage={game.dpl}:year,{game.dpl}:genre,{game.dpl}:publisher,{game.dpl}:developer,{game.dpl}:engine,{game.dpl}:character

Does the template extension work when specifying specific template parameters/fields to include? Also, it seems counterintuitive to require the ".dpl" outside the curly braces {} considering the template name is template:game.dpl not template:game.dpl. -Eep² 00:44, 29 July 2007 (CEST)

  • You should ONLY write 'include:{game}.dpl', nothing else. Leave all the parameter stuff away. Have a look at the DPL source code if you want. Firthermore there a lots of examples on this website which demonstarte how it works. The line in "somearticle" (which we assume calls Template:game is changed in a way that it now calls Template:game.dpl. All the parameters are untouched and two more parameters added (%TITLE% and %PAGE%). To me this is the _most elegant way_ to handle this whole topic. The code in Template:game and Template:game.dpl typically is significantly different to justify keeping it int two different templates. If we wanted to offer variables for substitution we would need prefixes for the template name and the parameter name (or number). Imagine your article includes Template:game and Template:hardware and you wanted to construct output from some parameters of both of these templates ..
84.58.211.73 07:56, 29 July 2007 (CEST)
I can imagine it quite easily, actually, and DPL should support it since it already supports multiple sections on different pages so why not multiple template fields on different templates? The "elegant" way seems like a copout copout (you really ought to add the wikipedia: interwiki link to your MediaWiki database...) to me... -Eep² 08:04, 29 July 2007 (CEST)

mode=none

Seems like this parameter should not display any results. I'm trying to do just a page count of how many items are in a particular category: {{#dpl:category=Games|mode=none|resultsheader=(%PAGES%)}}. But this results in:

(3)
Game 1
Game 2
Game 3

How do I get just a page count? -Eep² 22:23, 27 July 2007 (CEST)

take mode=userformat and do not specify listseparators. That will produce no results. 'mode=none' is kind of a relict of ancient times ... Gero 23:38, 27 July 2007 (CEST)
Doing that screws up bullets:
And if I have a superscript after it, it messes up even more:
I want the "(#)" to be in-line and not put blank lines after the output but, of course, that is only with "mode=inline", right? :/ Also, how would I get the last row in a table/list to be totals of the above rows/lists? -Eep² 05:22, 28 July 2007 (CEST)
You are right. If you want to have inline (#) sums of articles DPL must not add an implicit newline after ther reultsheader or resultsfooter. So I removed that. As a consequence you must add a \n after a resultsheader if you want to create a headline with ==x== notation. That is acceptable, I think. Version 1.3.1 has this modification as you see. PLease have a look at Test resultsheader!
Gero 08:13, 28 July 2007 (CEST)
Thanks for fixing this. -Eep² 22:07, 28 July 2007 (CEST)

example code within the manual

The example code at hlistattr (and some others) creates unwanted effects on the TOC table. I would rather see all examples as separate files, (a) the code of the example and (b) the actual example itself. The manual could then include the example code directly and with nowiki tags around so that the code need not be duplicated. "selfhtml" shows how to do this. I suggest that you change hlistattr that way and that we agree on a standard way how to do it based on that example. Gero 14:29, 17 August 2007 (CEST)

Inserting spaces and comma in the output

  • I'd like to simulate the mode=inline behaviour, but removing the namespace of the links.

So I wrote {{#dpl:category=MyItems|listseparators=,[[%PAGE%|%TITLE%]] ,,}} which correctly renders Item1 Item2 Item3 Item4, but how to insert a comma between the items ? Yopai 20:44, 20 August 2007 (CEST)

I solved it (if any better solution, I'll be glad to take it) by hacking the code :
  • adding a parameter inlinetext=,%SPC% before the "listseparators" parameter
  • modifying the code so the "listseparators" doesn't empty the "inlinetext" variable.
  • replacing, inside inlinetext, '%SPC%' with ' ' (I also had the problem of spaces being trimmed when used in inlinetext, and I did'nt want to use   which would have cause my line not to break)
Hope it can be useful. Yopai 20:44, 20 August 2007 (CEST)

Reply

I think there is no nbeed to change the php code. Just use &#44; as an alias for a comma; you can keep the space after that 'comma', so line wrapping will work normally:

{{#dpl:category=MyItems|listseparators=,[[%PAGE%|%TITLE%]]&#44; ,,}}

Gero 18:17, 22 August 2007 (CEST)

Replace category lists

How can I replace the default MediaWiki category lists with DPL-generated lists instead? Also, I'd like lists to optionally sort mixed-case alphabetically (not separating CAPS and lowercase letters)--is that possible with DPL? And I'd like to have the columns equal size like they are on http://www.tnlc.com/wiki/index.php?title=Category:Templates in MediaWiki's default category list but not in the DPL-generated list. -Eep² 15:09, 29 August 2007 (CEST)

I did not think about replacing the default category lists so far. Maybe there is a hook for that? If you find a canonic/legal way to do it I might be able to offer taht feature. But I will not offer a solution that would require to patch mediawiki source code.
Why not?
Regarding case-insensitive sorting: There seems to be a simple way to do it with SQL. So I will be able to offer that option in one of the next releases.
OK, how is it done--do you have a link? I'd like to change how MediaWiki sorts things by default throughout anyway.
o.k. with 1.3.6 Gero 16:53, 30 August 2007 (CEST)
changing mediawiki as a whole requires direct changes to the database and/or to MySQL (defining own collation sequences). There is literature on that in the MySQL world ... Gero 16:53, 30 August 2007 (CEST)
Thanks.
Equal size for columns or width=100% is possible with 'rowcolformat'. I changed your example accordingly.
Gero 21:53, 29 August 2007 (CEST)
Thanks; I corrected the parameter and added more info to it but how do I get equal column widths? I tried rowcolformat=cols=3 but that doesn't seem to work. I guess I have to set specific widths for each column--is there a way to set a width for all columns (without having to specify a width for each column)? -Eep² 23:09, 29 August 2007 (CEST)
you may want to try setting colwidth to 33%. Read SELFHTML to understand whether this works.Gero 16:53, 30 August 2007 (CEST)
SELFHTML? A link would be nice since there is no colwidth HTML tag... -Eep² 22:51, 30 August 2007 (CEST)
selfhtml is a wonderful online manual explaining everything about html, JavaScript, css etc. Its root is in Austria, so it is in German. There used to be an English version but it may be outdated. Anyway, you would have to use DPL rowcolformat to assign a special class to your table and then you should be able to define css properties for that class in the article mediawiki:Common.css. At least I think it should work like that. You have to find out yourself. If it works it would be nice if you published the solution under FAQ... 09:11, 31 August 2007 (CEST)
Well, unfortunately, I don't know German (or French) so SelfHTML (that wasn't so hard to put a link to, now was it?) is out for me. Doing a simple Google search for "colwidth" turned up non-HTML syntax unusable in MediaWiki and with DPL. How would I define a class for mode=category? Oh and thanks for adding the other booleans. -Eep² 09:43, 31 August 2007 (CEST)

(You may have to clear thebrowser cache or use CTRL-F5 to display the above table correctly). Gero 14:02, 31 August 2007 (CEST)

{{#dpl:titlematch=N%|columns=3|rowcolformat=class=dpl3columns}} is not for mode=category...and there's 4 columns. -Eep² 15:05, 31 August 2007 (CEST)

Compare the template field values??

Is it possible to compare the field values of two same templates: One template in a category and one in those articles belonging to this category. For example, Template:Country in a category has population field with value of 15million. In an article, there is also a Template:Country with population field. What I want to do is that if the population value changes, then the article meets the criteria and will be output in a table to show the changed value like this:
Country|population|
catname|15million|
article1|17million|
article2|18million|
Any idea? Thanks, Guoqian 10:41, 1 September 2007

Answer

This is quite easy to do. Either you write querty which simply picks up all template calls for Population (regardless where they may be) or you build a set of two queries which are directly reflecting your problem structure. I think your example may be of soime relevance to others, so I created some test files and a Population Checker template. See Category:Country. Gero 11:10, 2 September 2007 (CEST)

Question1

This is nice but it seems still showing those articles having the same value with its category. See Template:Population Checker, I added an article Nig3 having population of 5.3 million. I donot want to show this article in table because the population value is not changed. I mean I only need articles with changed value to be output in a table. Can DPL filter out this one? Thanks, - Guoqian 8:59, 2 September 2007

Reply

It is possible. You would have to use a DPL query which outputs just the value of a single parameter (which is possible) and use that result as an argument for the 'includematch' parameter of a second DPL query. I suggest that you try yourself. Gero 20:36, 2 September 2007 (CEST)

Question2

OK. I added a Template:Population.dpl2 to show a single population figure and made a DPL query in Template:Country Population to get the value of a specific field for a specific category. In Template:Population Check, I call template Country Population as the parameter of includenotmatch. It works well if I pass a specific country name. See Template:Population Checker
One question is that how I can pass the field name (country name) to template Country Population without a specific value. I mean different articles have different country names or one article contains different country names.
Another question is that how I can make the country names as column headers and population figures as row entries like:
article|Nigunda|Tosuna
catname|5.3 Mio|2.1 Mio
Nig1|7 Mio|-
Nig2|2.1 Mio|-
Nig5|-|3.2Mio
Nig10|3.3 Mio|4.3 Mio
Is this possible by using DPL? Thanks. -Guoqian 5:01pm, 3 September 2007

Reply 2

  1. If you simply want to get the value of one template parameter you don´t have to invent an extra template. Just put the field name or field number after the template (preceded by a colon). I changed your code in template Country Population accordingly.
  2. I did not know that in your case an article could have statements about more than one country. Therefore the current design is not ideal and would become too complicated if you extended it via, let´s say, another DPL loop around the top level checker.
  3. In your case it is much easier to pick all invocations of the Population template (regardless of where they may occur), then output article name, country name and figure and finally throw it into a sortable list. Then click once on the country column and you will have the conflicting entries right beneath each other.
  4. Could you try that and show us the result here?
  5. As for your last question: As far as I am aware of, the current design of DPL does not allow flipping columns and rows (in neither approach). But sometimes people come up with things I didn´t think of. So, who knows ..
Well, would you consider adding this functionality in DPL please? I really need this for my comparison table so it doesn't get excessively wide, causing scrunched columns or horizontal scrolling! -Eep² 00:36, 5 September 2007 (CEST)

--Gero 19:46, 4 September 2007 (CEST)

Question 3

  1. In your second point, you did not point out how a dynamic value can be set as an input value for a template call in includematch. Without this support, I can not filter out other population figure having the same value with its category. For examples, Nig4 can not be excluded in this way. I tried something like: includenotmatch=/\s*{{Country Population|{{{1}}}|Nigunda}}*/s,/\s*{{Country Population|{{{1}}}|Tosuna}}*/s. But it does not work although in includenotmatch, it has syntax as includenotmatch=regexp1,regexp2,.. . Can you explain how the regexps would work together? You mentioned we may need a new design. Can you give an example design for this problem?
  2. In my use case, Category:Country also has several subcategories like Category:CountryA and Category:CountryB. I donot want these subcategories to be output in wikitable. How can I exclude these matches for subcategories?

--Thanks, Guoqian 9:01pm, 4 September 2007

Use nottitlematch. -Eep² 04:40, 5 September 2007 (CEST)
How does this work? You mean I put nottitlematch=%CountryA%|%CountryB% in the creteria list. It seemed only working for CountryA (is it a bug?). see Template:Population Check. Even this works, it is not the way I desired. I believe there should be a way to exclude the direct/all subcategories.Thanks, -Guoqian 9:37am, 5 September 2007
I got it. I added "namespace=" for matching those only in articles. I am not sure if this is the best solution but this works.


This is a check of Country for consistency of population figures.


article country population
Category Country Nigunda 5.3 Mio
Category Country Tosuna 2.1 Mio
Category Nig1 Nigunda 5 Mio
Category Nig2 Nigunda 7 Mio
Category Nig4 Tosuna 2.1 Mio

-Guoqian 10:11am, 5 September 2007

Question 4

  1. How can I disable "%DPL-1.3.9-WARNING: No results!" if no results return?-Guoqian 12:11am, 9 September 2007
See the manual (debug or noresultsheader). Gero 08:46, 9 September 2007 (CEST)
Very nice. "debug" works very well. It seems that empty string for noresultsheader does not work although a Note "Setting noresultsheader to the empty string ("noresultsheader=") will suppress the warning message from DPL" which is normally issued if no articles were found. " is mentioned in manual. Thanks, -Guoqian 7:05, 9 September 2007

Question 5

  1. After I use titlematch=%abc% and get a list of matched pages, I want to filter the results and recieve those only having a specified value of a template. Say Temaplte:Kind, having possible values "KindA", "KindB", etc. I only want those results with "KindB" for Template:Kind. (Note:output format will use a different Template). Any idea? Thanks, -Guoqian 11:00, 10 September 2007

replaceintitle

I'm trying to use a magic word in the search term for replaceintitle:

{{#dpl:
namespace=
|titleregexp=^{{PAGENAMEE}}/
|columns=1
|ordermethod=lastedit
|shownamespace=yes
|addeditdate=yes
|adduser=yes
|order=descending
|mode=userformat
|replaceintitle=/{{PAGENAMEE}}/,
|listseparators = ,[[%PAGE%|%TITLE%]]<br/>,
}}

When I do this I get an error:

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'C' in /home/rob/www/extensions/DynamicPageList-1.4.2/DynamicPageList2.php on line 3134

The DPL query is being used from within a template. Also thanks for making DPL - it makes lots useful things possible! --Rob 02:54, 11 October 2007 (CEST)

Reply

Maybe some of your pages are subpages. Then PAGENAMEE would contain a slash and the letter after the slash would be understood as a regexp modifier. You should apply a {{#replace:{{PAGENAMEE}}|/|\|}} or so to escape slashes or you should use a different regexp delimiter symbol.

Gero 09:06, 11 October 2007 (CEST)
Yes, you're right. When the query works when the pagename has no / but when it is iself a subpage the error occurs. Thanks for your help. --Rob 00:20, 12 October 2007 (CEST)

DPL and image gallery

Hi all, sorry if this question is not properly placed or stated. I need some hints about this problem: I need to create a gallery with images from a category. First I started with this piece of code:

{{#dpl:
  |category = {{{categoria}}}
  |namespace = Image
  |mode = userformat
  |format = «gallery»,%PAGE%¦%TITLE%\n,,«/gallery»
  |noresultsheader = No image in this category.
}}

But the result is not so good, as you can see here:

http://www.usnb.it/wiki/index.php?title=Test:TestGallery

all the coats of arms are in the same size, but the pictures differs because there are different crowns. The resizing in thumbnails is not so good....

Thus I adopted this solution:

{{#dpl:
  |category = {{{categoria}}}
  |namespace = Image
  |mode = userformat
  |format = «table border="1"»«tr»,«td valign=bottom»²{ImagePerc¦immagine=%TITLE%¦larghezza=100¦descrizione=%TITLE%}² ,«/td»²{#if: ²{#pos:%NR%¦0}² ¦ «/tr»«tr» ¦ }²,«/tr»«/table»
  |noresultsheader = Nessuna immagine in questa categoria, per il momento.
}}

ImagePerc is a template able to resizing an image both by percentage and pixel width:

[[Image:{{{immagine}}}|{{ #if:{{#pos:{{{larghezza|100}}}|px}}|{{{larghezza|100}}}| {{#expr: ({{#imgw: {{{immagine}}} }} * {{{larghezza|100}}}) / 100 }}px }}|{{{descrizione|}}}]]

where #imgw is a parser function able to retrieve the width of the given image.

The result seem better, but the </tr><tr> are rendered as string and not tags, despite the DPL escape characters adopted.

http://www.usnb.it/wiki/index.php?title=Template:CategoryGallery2

Any hints? Thanks --GB 23:51, 23 November 2007 (CET)

[SOLVED?] after a while, I noticed that setting $wgUseTidy = true; seems to work :-) --GB 00:49, 24 November 2007 (CET)

tablerow-Like Parameter.

Is there a parameters similar to tablerow that'll let me process each individual included component without having to use a table? Example:

include={sometemplate}:a:b:c
format=,\n* '''[[%PAGE%|%TITLE%]],,
???=<sup>{{#if:%%|M}},{{#ifeq: %%|filler|X}}</sup>:, ''' %%,

Essentially, I want the end result to build the wiki-markup:

* '''[[Issue:Adduser|Adduser]]:''' Yadda yadda.
* '''[[Issue:Collation|Collation]]<sup>M</sup>:''' blah blah.
* '''[[Issue:False result count|False result count]]<sup>X</sup>:''' Yackety schmackety.
* '''[[Issue:Modularize DPL Code|Modularize DPL Code]]<sup>MX</sup>:''' blah.

which will be displayed as

Sledged (talk) 23:33, 29 January 2008 (CET)

Currently there is no such parameter. Feel free to add it. Currently I am not working at the DPL source.
Gero 22:51, 30 January 2008 (CET)

discussion board lookalike

Dear Friends,

let me start with a compliment. DPL seems to be a great tool. Maybe it could be configured in the following way:

I am looking for a "simulation" of an online-discussion-board to invite extern board-communitys to Wikiversity. The goal is to build a common platform usable by various private websites, but in wiki-syntax.

Treads, subjects, themes listet, if last edit is not older than x days. It should "feel" like an PHP-board or something. Various extern Webmasters could implement this "wikiversity-board" instead of an PHP-board to participate with a larger community. A single webmaster often has only an hand full of members, but each webmaster is making in the same subject (physical science). It could be a benefit for the webmasters and for US. Therefore a "real" discussion-board would not be acceptable. We are looking for new users.

Unfortunately extern discussion-communitys hangs on there own "look and fell". Its like "reactance against new things". I want to close the gap by providing a "lookalike". A "surface" to make it easyer to implement it on extern websites. It should be quite similar than a real discussion-board but based on regular wikimedia-pages. Is this possible? Has someone an idea?

Howto configure DPL in a table? --CFT 02:31, 12 March 2008 (CET)

To be honest, I do not understand what you have in mind. Using SimpleForms and DPL you could build a system which offers a dialog box to add comments or new pages and you could create overview tables; the outcome could be similar to the 'Issue' system here in this wiki...
Gero 00:39, 13 March 2008 (CET)


Formatting first table column

I would like to know if there is a technique to format the first cell in a table row. I've seen that using tablerow it is possible to format all the include parameters related cell. But what about the first (i.e. the article cell) one? Probably do I must use a phantom template? --GB 20:46, 28 July 2008 (CEST)

Yes, if you want to format the column which contains the link to the article in a different way you must take over control completely by writing your own phantom template. The table statement tries to keep syntax simple ... Gero 21:19, 28 July 2008 (CEST)

mmm... sure I didn't understood... :-) well, you stated that:
  • I must avoid to use table statement and use a phantom template instead (argh!), or
  • I must use table and tablerow statements and a phantom template for include statement, or
  • I must use table and a phantom template returning the syntax for a table row, or
  • nothing of the previous :-)
BTW, probably I understood that (and how) it is possible to include one or more templates and related parameters, but probably I didn't understood how phantom templates work :-) --GB 14:14, 29 July 2008 (CEST)
[SOLVED?] Well, probably I solved in this way:
  • I added the magic word PAGE with double square bracket after the template name in the include statement
  • I placed a minus sign in the table statement to avoid the header for article column, and I added a new header
  • I added a new placeholder in the tablerow statement to take in account the new column, with the desired format (for test, just a simple alignment html attribute
It works! You can see it at Riepilogo Creature. Well... too simple... what I'm missing??? :-D
PS. Tks again for your wonderful and powerful extension... --GB 14:42, 29 July 2008 (CEST)

Strange behaviour with tablesortcol

There is something strange (or is it an expected behaviour?) when the column specificated by tablesortcol parameter contains the same value in different cells: only one row is displayed for each value, but the PAGES magic word returns the sum of all pages selected. You can see some examples at, where also the distinct parameter is tested: [1] It seems a bug, but probably this can be related to my low experience in DPL... --GB 23:18, 30 July 2008 (CEST)

Last uploaded picture

Hi everybody,

I would like to display the last uploaded picture (with its description) on my main page. Here is the code :

<dpl>
namespace=Image
ordermethod=lastedit
order=descending
minoredits=exclude
escapelinks=false
count=1
includepage= %0[36 more..]
format= ,[[%PAGE%|%TITLE%|130px]]<br/><span class='lastUp_details'>,</span>
</dpl>

I get the picture, but the caption isn't displayed properly. And I'd like to display the first 36 characters of the caption, then cut it with '...'.

Any help welcome ! -- Marineam 15:30, 13 October 2008 (UTC)

Breaking spaces instead of non-breaking spaces

Hi Gero,

Instead of recommending &nbsp; to insert spaces in the inlinetext parameter, you can also use &#32;. This will properly break lines without adding multiple spaces.

Jeanmarc 06:47, 18 December 2008 (UTC)

You are absolutely right - in many cases people might prefer normal 'breaking' spaces. I added a remark about that. Gero 23:46, 18 December 2008 (UTC)

Include template values in userformat ?

I'm playing with dpl over at the demigod wiki and i'm trying this:

<dpl>
category=Queen of Thorns Passive Skills
include = {Skill Box}:name:description
table     = ,,name,description
tablerow= [[image:%%.png|20px|%%]],''%%''
</dpl>

What I'm doing is grabbing the name and description field from the skill box template used in all articles of a certain category. Then I want to rearrange the text to suit my tastes.

Above example works nice, but i don't want a table. I'd rather have something like an inline output and I'd intuitively write the code something like this:

<dpl>
category=Queen of Thorns Passive Skills
include = {Skill Box}:name:description
format= [[image:%name%.png|20px|%name%]] [[%PAGE%]] - ''%description%''
</dpl>

A small linked image, followed by the page, followed by a "-" followed by the description in italics.

I couldn't figure out even with the manual how to do it.

Any ideas ? Aroddo 17:58, 14 May 2009 (UTC)

You have to use listseparators, secseparators and multisecseparators. With these commands you can create your individual formatting of the output. Sometimes you will wonder why the output does not conform to your expectations. In these cases it helps to use "debug=5" to see the wikitext which is being produced by your setting of the above mentioned parameters.
Gero 20:05, 14 May 2009 (UTC)
Thanks, that actually helped. Aroddo 14:32, 15 May 2009 (UTC)

replaceinsection...

possible to add something like this? Dpluser 21:08, 17 September 2009 (UTC)

You can use #replace within a tablerow statement or within a phantom template. In addition the next version will allow regular expressions to be applied to included chapter content. Gero 06:08, 18 September 2009 (UTC)
Unfortunately this isnt working, I am actually trying to remove some wiki table markup from the transcluded chapter. Because %% is expanded before the #replace or even tried #explode is called it fooks up the function call.Dpluser 14:11, 18 September 2009 (UTC)
actually i was able to solve a previous formatting problem that required me to use tables in the first place, which indirectly removed the need for this.Dpluser 19:37, 18 September 2009 (UTC)

{{PAGENAME}} inside a template

I'm just getting started with DPL and it is pretty amazing! I apologize beforehand if this sounds really noobish, as I do not know any regex, but here is the problem I am having. I have a ingredients template on my wiki that has a {{PAGENAME}} on the first line. If I stick a

{{#dpl:title=Vanilla Ice Cream|include={ingredients}}}

on the "Vanilla Stuff" page, for example, it will display "Vanilla Stuff" instead of "Vanilla Ice Cream" inside the outputted ingredients template. While I suspect that there is more than one way around this, what is the "right" way to fix this, without modifying the template? --J.nesta 03:43, 27 September 2009 (UTC)

Reply

Your DPL statement uses the title= syntax which means that it will not output the page title by default. Specifying the template name without any suffix or appended variables will output the content of the template in its original form. So you should see the same content on your "Vanilla Stuff" page that is shown as a result of calling the ingredients template on page Vanilla Ice Cream. For some strange reason, however, a trailing delimiter is needed before closing the dpl statement, so you must add a space char after {ingredients}.

See the difference in the following two examples:

a) without trailing space: {{#dpl:title=Somango|include={Country}}}
b) with trailing space: {{#dpl:title=Somango|include={Country} }}

Gero 07:55, 27 September 2009 (UTC)

Reply

I see now; in A nothing gets outputted at all, and B works correctly. But with regards to my original problem:

So you should see the same content on your "Vanilla Stuff" page that is shown as a result of calling the ingredients template on page Vanilla Ice Cream.

This is false. As I've said, the {{PAGETITLE}} is being parsed as the page I am invoking the DPL from, not the page of the template I am calling. I've gone ahead and created Template:Test2 to illustrate, as well as adding a {{Test2}} to the bottom of the Sandbox. Now, when I do a

{{#dpl:title=Sandbox|include={Test2} }}

It spits out:

Template:Test2.default

See? Can I correct this by modifying my DPL statement somehow? And before I forget, thanks Gero for your extremely quick reply; I went to bed after I posted this and I woke up with a response already! <3 =) --J.nesta 12:09, 27 September 2009 (UTC)

Reply (3)

Unfortunately you can`t. PAGENAME will always return the value of the top-most page. That is obviously how it was designed. If you have a page A containing a DPL statement which outputs the name and some content of page B and if B includes a template C and you want to use the name of B within C then you must pass B´s name literally when calling C as a normal parameter. And you must use that parameter within C and not the PAGENAME macro. When creating page B you may want to use an edit/copy template which contains {{C|page={{subst:PAGENAME}}|...}} to avoid misspelt names. When saving a new page based on this piece of text the name will be expanded correctly. If you change the page name later, however, you will have to change the parameter manually. Gero 19:21, 27 September 2009 (UTC)

Tablesortcol issues

I have two quick questions, mostly due to my inexperience with dpl. First, i was wondering if there was a way to use the tablesortcol feature without having it restrict output to only one instance of each value? For example, I'm attempting to sort a column with various state names that each appear multiple times. Using the tablesortcol feature results in each state only getting listed once in the right order. Also, is there a way to sort numerical or date values using tablsortcol? Thanks for any help. --Josh 8:17, 7 October 2009

format for generating a link

I use DPL to automatically generate a graph with an extension for GraphViz (similar to aiSee ...) I wrote some utility templates to easily generate the appropriate syntax, it's just great ;-)

However I have a problem when I try to generate hyperlinks (GraphViz can generate .map files) this way :


{{#dpl:
 |category=mycat
 |namespace=
 |format=,\n{{Node|%PAGE%|url={{localurl:%PAGE%}}}},,
}}

The {{localurl:%PAGE%}} function isn't evaluated correctly: all my links point to the wikipage named "%PAGE%" which is obviously not the goal. Is it a bug ? is there somthing like a %LOCALURL% I could use ? Or can I curcumvent this using the secseparators and multisecseparators, in which case I must confess I have no idea how to do it ...

Thanks !

--Goulu 13:04, 28 April 2010 (UTC)

Please read the chapter in the DPL manual on expansion mechanisms and treatment of special characters.
You must use ²{ ... ¦ ... ¦ .... }² instead of normal wiki syntax within the format statement because you want the text to be expanded within the result traversing loop of DPL and not before DPL is invoked. Good luck! Gero 19:54, 28 April 2010 (UTC)
Thanks, I skipped this one... Then I noticed the ²{ ... }² worked on your wiki, but not on mine... And the I upgraded DPL to the current version 1.8.9, and now everything is perfect. Thanks a lot !
--Goulu 06:02, 29 April 2010 (UTC)

how to process CATNAMES ?

I'm now trying to generate a graph of categories using GraphViz. I generate edges in the graph using :

{{#dpl:
  |namespace=Category
  |addcategories  = true
  |categoriesminmax=1
  |mode=userformat
  |format=,\n"%CATNAMES%"->"%TITLE%";,,
}}

It works well, except for categories that are subcats of more than one other category. For example on your site, the above generates

 "Cities, Germany"->"Hamburg";

while I need

 "Cities"->"Hamburg";
 "Germany"->"Hamburg";

How can I do this please ? Thanks ! --Goulu 05:49, 20 May 2010 (UTC) (sorry I forgot to sign)

You have to call a sub-template within the format statement using the ²{...}² syntax rules (see DPL manual). WIthin the template you can use a regular expression to replace each "," by an arrow an the %TITLE% symbol. Note that you must also pass %TITLE% as a parameter to you sub-template.
BTW: What do you think of Wgraph? It should be able to produce the kind of chart you want to generate (aiSee is extremely powerful); you can even find examples of link graphs here on this demo web site: See "GUI" in the navigatin tree and press the "graph" link, and then "create graph".

here is a very simple example

... Gero 16:15, 19 May 2010 (UTC)

Ok, I'll do the ²{...}² trick again, I thought there was a way using listseparators and secseparators ...

Wgraph (and aiSee) look nice, but we're using Graphviz for a long time, and it's very powerful too...

The wiki I'm setting up is to document a huge code library, and we were using doxygen for this till now, and doxygen uses graphviz to generate "UML" graphs. We're also using ZGRViewer to display and navigate a huge graph with the whole library. However, it is more difficult than I expected to allow users to produce simple graphs using the wiki syntax...

By the way, since you became my "wiki programming guru" ;-) , I have a challenge here : http://en.wikipedia.org/wiki/Help_talk:Template#.3Cpre.3E_Challenge (not related to DPL) ...

Thanks again for your great work

--Goulu 05:49, 20 May 2010 (UTC)

Suppress articles without included section

I am looking for a way to suppress articles in the output which don't contain an included section. See DPL:Manual - DPL parameters: Controlling output format#Example for the current behavior.

See DPL: Restrict output when using "include" for sections for the discussion in the mailing list. --nakohdo 16:10, 14 February 2011 (CET)

tablesortcol : negative values for inverted sort do not work as expected

I try to list the last patents referenced on our wiki with:

{{#dpl:
 |namespace=
 |namespace=User
 |uses = Template:Cite_patent
 |ordermethod=none
 |include={Cite patent}:country:number:title:status:gdate:assign1
 |table=class=wikitable,page,country,number,title,status,gdate,assign1
 |tablesortcol=-6
}}

Problem : tablesortcol=-6 gives a funny "gdate" ordering, definitely not the reverse sort of the one obtained with tablesortcol=6, which looks correct. Any idea ?

Besides, I wonder how to list only the most recent 10 patents, or alternatively those which are less than 1 year old provided gdate is in yyyymmdd format.

Thanks!

--Goulu 14:03, 7 June 2011 (CEST)

Parameter for categories / phantom templates

If would be nice if there was a way to tell (from the phantom template) which categories were called in the DPL call... or at least have a way to pass parameters to the phantom template. If there is, I was unable to find information here about it. addcategories = true is similar (and works from the phantom if included) but lists the categories the target page is in rather than the categories from the DPL call. I need to be able (from within the phantom template) to output information dependent on categories and would like to be able to do so without creating multiple phantom templates (one for each category so as there would be no test within). Rappy 23:06, 29 April 2012 (CEST)

Can you create an example in this wiki of what you are trying to achieve exactly? I'm not quite sure what you mean. Until it is clarified, I can only guess and suggest these two things:
  1. Try to employ {{#dplreplace:j|i}} to remove/replace undesires categories from the %CATNAMES%/%CATLIST% variable; for example {{#dplreplace:{{{%CATLIST%}}}|\[\[:Category:Beautiful_babes.Beautiful babes\]\],?}}.
  2. Try to make a non-phantom-template call, i.e. have your dpl call select the desired articles and then pass those on to a template with your parameters in the format parameter format = ,\n²{output¦%PAGE%¦%PAGESEL%¦%CATLIST%}²,,; here, you would call the Template:Output and pass on the parameters %PAGE% as {{{1}}}, %PAGESEL% as {{{2}}} and %CATLIST% as {{{3}}}, from which you should be able to process the parameter values in any way you want.
--Theaitetos 01:54, 30 April 2012 (CEST)
It would be a pain to try and recreate here. Option2 is probably doable, but would be a pain to manually list every param from select=. Basically, I have a DPL call similar to {{#dpl: category = blah¦blah2 | include = {Test} phantom | format = <table setup>}} and am trying to do a check in Template:Test phantom to return the original two categories from the call, namely Category:Blah and Category:Blah2 OR pass one or both to the phantom template as a parameter. %CATLIST% can be passed to the phantom template but is the list of ALL the categories the selected page belongs to... not the category that was selected in the DPL call. My alternative (at the moment) was to create separate phantom templates in the fashion of Template:Test blah (the 'blah' being in reference to Category:Blah) so that I know when I include that, it was based on a DPL call on that particular category. My goal is to have an encompassing phantom template that could detect which, of multiple, categories was called originally. Rappy 03:00, 30 April 2012 (CEST)
What about making several dpl calls, i.e. one for each of the categories. That way you can simply pass the category to the template as a fixed parameter. Otherwise give me a link to your wiki and the page of your dpl call and I have a look. --Theaitetos 00:48, 1 May 2012 (CEST)
I was unaware you could pass params to phantom templates. If I can, this shouldn't be an issue at all. As far as a link, it's for a skills list for Aion Wiki. Some skills are known by multiple classes at multiple levels. I do a call of Category:Spiritmaster skills which could be referenced in the infobox on that page as class= or classx=(2-6). The level (based on class) follows the same format of level= levelx=(2-6). For instance, if the SM gets a skill at level 19, but is listed in the infobox as class2=, the corresponding level for that class is level2=. The other levels may or may not be the correct level for that class. The DPL call, and the phantom template, are located here and here. Please note, they are currently being tweaked and are not in complete working order. I added a comment in the code. (Feel free to edit if you feel inclined. The pages are not widely linked to and will not cause confusion.) Like I said above, I could always create Template:Skillinfobox cleric and only use that one when referencing a DPL call on Category:Cleric skills, but I'd like to be able to have one phantom for all 8 classes and be able to tell which one I am calling within the phantom. Rappy 01:08, 1 May 2012 (CEST)
I see what you mean now. Unfortunately I do not think there is an easy workaround, as there is no %CATSEL% like there is an %IMAGESEL% variable. If you're willing to omit the presorted table, you can use the workaround I edited in. Basically you create one table out of several dpl calls, which requires the parser function mode of DPL. That way you can also use templates and parser functions within the format and/or tablerow parameters, thereby making the phantom template unnecessary. I hope this works for you. --Theaitetos 14:07, 1 May 2012 (CEST)
I replied on Aion before I realized you replied here to. Rappy 22:09, 1 May 2012 (CEST)

Revisiting

I've been fooling around with the tablerow and tablesortcol params and I notice that they don't always sort the same way. Additionally, sometimes when sorting by a certain row, half the pages seem to disappear from the list. I've made a example page on Aion. Am I missing something? Rappy 02:16, 25 May 2012 (CEST)

Inject CSS into table headings of table

  • Is there any way to put CSS into a DPL table heading?

The background for this in case it's useful is to integrate a filter (http://www.javascripttoolbox.com/lib/table/documentation.php) into a DPL generated table. This needs something like the following, to make the CSS go into the TH HTML tag

|table=class="table-autofilter",-, Number, class="table-filterable" Function, Name, Type, Owner

Ianb1469 (talk) 12:22, 11 August 2014 (CEST)

I've answered my own question now: |table=class="table-autofilter",-, Number, class="table-filterable"¦Function, Name, Type, Owner