DPL talk:Manual - DPL parameters: Controlling output format

From FollowTheScore
Revision as of 22:07, 28 July 2007 by Eep² (talk | contribs) (mode=none: thanks)
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)

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:
<nowiki>
{{#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%'''
}}
</nowiki>

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²

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)