Forum:Multiple templates in DPL

Hey,

I'm one of the Admins at w:c:Wakfu.

After a discussion with one of our members, I wanted to start using DPL on the site to generates some sortable tables of things. The problem is, most of the pages consist of multiple small templates, and my current level of DPL just about grasps the ability to handle one template in each article.

So, I was wondering if it was possible to select a take information from multiple templates in each article, put that information all in the same table row (so when you sort each column, the information from a single article stays together, etc)?

The member I was talking to, who came from the w:c:Dofus wiki, was basically saying we need a single giant template to cover everything that you'd want to call up with a single DPL table, but I was hoping DPL was flexible enough that the current templates/articles could be left untouched, and editing a page could be left as simple templates, rather than a giant wrapper-template generating the small ones (i.e. I don't want to trade a simplicity in editing for DPL functionality).

An example article: Ash Bow which uses:
 * The "Itembox" template which contains simple things which apply to every item in the game
 * The "EffectStub" template which contains the effect of the item when held/worn.
 * The "Attack bow" template which contains the effect of the bow's attack.
 * and the "Craftbox" template which contains the information about crafting the item.

What I have so far:
 * The Bow article, with a table of the 2 bows on the wiki, showing just the information pulled from the "Itembox" template. (lists the item's name, level, and description)
 * The "Infobox Weapon.Table" Template (there is some old info/code which I've left in the non-code part of this template so I can take ideas from it.. but it actually generates the basic table shown on the "Bow" page).
 * The "Itembox.TableRow" Template which fills the rows, with data taken from the "Itembox" on each article.

An example of what I'd like to be able to do:
 * On the general Bow page: a table showing each item's name, level, passive effects, attack effects, and if there's a craft template present (i.e. is it craftable)... without changing/adding any more templates/wrapper templates to the "Ash Bow" page.

Hopefully, I've made it clear what I'm trying to do.

Thank you for your time, and any help you can give me --Defunc7 15:11, May 4, 2011 (UTC)


 * Because you're using a surrogate template which you also use to format table rows, I don't see a way to derive data from more than on template without causing the output table to break, with that dpl structure. However, you could just call various template parameters 'manually' and replace the hard-coded table tags with the  dpl parameter. That would certainly make the table more flexible. From there you would have more options on how to proceed including a new surrogate template to allow more complicated queries. On my user page, I've created an example list showing how I would tackle the problem.


 * Regardless of how you proceed, the articles that you're about to include in the dpl need to be standardized to make it work. Sovq 16:06, May 4, 2011 (UTC)


 * I looked at your example, and it really helped me move forward. I also tweaked my original attempt (I also tried mixing Bows and Wands to test how I could expand it).


 * Following your example, I made DPL Table, and my original version Template:Infobox_Weapon.Table... I prefer your version since it since much easier to work with (rather than multiple templates every time I want a different looking table), and I get less errors (which I'm not sure how to "handle" either)... but I've hit two issues.


 * 1. I can set the individual table cells as valign=top but not the first column with the article name/link. I would normally do it by applying the attribute to the table row... but I can't work out how.


 * 2. Items can be either "crafted", "loot", or "prizes"... I was hoping to check to see if the page has the specific template in use, and then display an icon/letter depending on which. Is there any way to test that in the DPL structure to get this sort of result, or would I have to put a template on the page which wraps all three of those options (so I can simply read in the value saying which one it is, and then show the appropriate icon)... I'm not sure if that's what you meant by "standardized articles".


 * Thanks again --Defunc7 22:36, May 4, 2011 (UTC)


 * What you can do is add the information into the main template on the page, whether the template uses that information or not. This allows you to access that information with the include. Rappy 00:07, May 5, 2011 (UTC)


 * 1. I have suggested removing all the  tags and do the formatting using   and   dpl parameters, bacause that would make your table(s) more consistent in appearance and you could certainly avoid issues like the valign="top" one. I See the article titles aligned to the top so I guess you've solved that problem.


 * 2. I'm not sure where the "crafted", "loot", or "prizes" info can be found, as I'm not seeing it on the pages, but if it's stored as a template paramter then you can use the includematch dpl parameter. If the type of template itself is defining what type of item it is, then you probably could use regular #if parser function in the surrogate templates to call the data. But to be able to answer that question throughly, I would need to know where that info is stored. Sovq 08:27, May 5, 2011 (UTC)


 * From what I understood reading this, that if an item is craftable, it has an additional template on the page to show this information. If Defunc7 added the crafting information to the main template, he can access that information with the DPL query on the page with that template... whether or not that template does anything with those parameters or not. I do this quite often when dealing with DPL because of this limitation. The only way around it is to nest DPL calls in the main DPL query which is quite intensive on the servers and will be slow to load most tables. Rappy 18:39, May 5, 2011 (UTC)


 * In fact, looking at Ash Bow now, I can see that if all of these headers follow the same way... you can simply mesh all 4 templates into one to fill the page. Alternatively, you'd end up listing the information twice. Once in Itembox and again in Effectbox, Craftbox, etc... In other words, if you want to change nothing with your current way, simply add the information from the other templates into Itembox and use that for your DPL include. Something like...


 * then you can access all that information with one DPL query on Itembox. Itembox can still only parse what you've told it to parse without any problems. My other suggestion would be to do the itembox like above, and have the itembox call the additional templates Effectbox, craftbox, etc, with the information shown above if they exist. Rappy 18:47, May 5, 2011 (UTC)


 * Yes, the idea was that if an item was craftable, then the article would contain the "craftbox" template. If it was a dropped item, or a prize, it would contain a different template associated with those concepts instead (e.g. a "dropbox" template, or "prizebox" template). Though I haven't actually made those. (essentially the process would check for craftbox, and if not present, then check for dropbox, and then for prizebox). Depending on which, the table would set the value in the same table cell to indicate which one it was.


 * A similar thing I've bumped into, design-wise, is that each item has a "rarity", defined in the Itembox variable called "colorCode". Rather than specifically list it in text, I tend to use colour/bold text (through css) to indicate it. With the template+table elements, I can define the colour, but I can't see a way to run a switch statement within DPL, to set the style of a specific column.


 * I've managed to move as much of the "table template"-y stuff into a more dpl-style arrangement, with Itembox.TableRow being the last surviving template (the "rarity" test colours the 2nd column table cell), but the dpl itself is contained within a manual open & close for a table, rather than generated by the dpl itself.


 * The current results are on Template:Infobox_Weapon.Table (though the actual template on that page actually generates something else). The 2nd table uses the wikia.css to apply "vertical-align:top" to the table cells through the "dplTable" class (having problems actually getting it to align properly in Chrome as well). The top table just uses secseparators to place a.


 * As to mashing 4 templates into 1 (or doubling-up the information), that was one of the things I was trying to avoid in the first place, since giant multi-function templates make editting "scary" for some contributers. I'm not even sure what the final information each page will contain, so am vaguely reluctant to create templates for now, which may need even more stuff added at a later date. --Defunc7 00:29, May 6, 2011 (UTC)


 * You can import a whole section of the article, just like I've done on my user page. I guess that's not the result you were trying to get, but it's hard (for me at least) to try and figure out a solution for deriving data from templates, if the templates are not yet created.


 * Don't get me wrong; the surrogate templates, like Itembox.TableRow are the only way to do more comlicated queries, I was only suggesting you move the table formatting to the dpl itself and leave the surrogate template only to process the data. Once you have templates for crafted, looted and gifted items, I'm sure something could be figured out to achieve the result you were aiming for with parser functions within the surrogate templates. But I guess it would be easier if you just had one template (for example Template:Obtainable), that would define it by a, let's say, "|source =" parameter. Then you could just call that parameter and any other parameters you see fit from that template.


 * To change the text color in particular cells a surrogate template is also the easiest way, so the solution you're currently using in Itembox.TableRow is something I would suggest as well.


 * I'm sorry if I mislead you into thinking that the detail templates (like Itembox.TableRow) should be removed. I was only saying the table formatting should be moved from them. We're using a similar solution on the Sacred Seasons 2 Wiki and thanks to the fact that the formatting is stored within the dpltable template itself, the surrogate templates can store all sorts of complicated queries and formatting. Sovq 07:30, May 6, 2011 (UTC)


 * Hey, sorry for the late reply.


 * I've fiddled with it some more, moved out the specific "table" stuff. The best result so far, is 1b. on the template page.


 * After having a think, I had some ideas:


 * 1. The current "rarity" colouring is done through the LvlRarity Template, which creates a  with the colour (set with class-linked css), and text centered... but I can't see how to do that within the DPL structure itself. I.e. placing class=" {Itembox}:colorCode " as an attribute of the table cell containing  {Itembox}:level not via specific templates.


 * 2. I made DropStub as one of the templates that go with the pre-existing Craftbox template, just to see to give another template to test for (i.e. is it crafted, or dropped). I haven't made the "rewards" template, since it doesn't seem as big a step (at the moment I think it'd look basically the same as the "dropped" template)


 * Instead of creating a wrapper template that acts as all 3 "types" of items (craft, drop, rewards), I thought I could use a small template, ObtainFlag, and place that inside each of the existing templates (Craftbox, DropStub, etc), and within each of those templates set it so, ObtainFlag contains whether it is a drop, craft, or reward... But while DPL picks it up as being in use on that page, it doesn't seem to want to take the fixed value,  {ObtainFlag}.type , within the Craftbox/Dropstub templates... I'm guessing it doesn't work because the ObtainFlag value is set inside those templates, rather than on the actual articles... am I missing some option to go "deeper" and pull out that value?


 * Thanks again --Defunc7 16:43, May 11, 2011 (UTC)

1. I would deal with that just as you did in table 1 and 1b. Using a phantom template (Itembox.TableRow, Itembox.LvlRarity) that stores the formatting and the desired template parameters. More complicated queries, such as this one, are certainly easier to control with an additional template like that. You can input parser functions in such templates, I tried doing that within the dpl  parameter in table 2 but it didn't work regardless of the syntax, so my guess is the parameter does not parse functions and thus I don't see it being possible in through the dpl table itself.

2. I think DPL does not see the output articles use the  template and can't derive any parameters from it. Like you said, the template would need to be used directly on the page. I might be wrong on that, but I did various testing and dpl only found and displayed the parameters for the Template pages, which use the template directly.

— Sovq 18:56, May 11, 2011 (UTC)


 * I think at this point I'm gonna have to admit defeat in terms of using multiple simple templates (this "obtain" issue, and another problem with data-duplication when using DPL to pull out data from different weapon types), and put together a mega-template to feed all data into. Bit annoying, but at least I've learnt some things I should be able to use in other areas.


 * Thanks for all your help --Defunc7 16:57, May 12, 2011 (UTC)