Forum:Same data used at many pages via different template calls

I do not presume that templates are the only or best solution for what I have in mind.


 * Problem Statement: At a game wiki site information describing 120-150 skills must be organized as records of some from or another. Currently they exist as parameter value pairs in template calls. Each of these "records" is comprised of 30 pieces of data per skill. The data types are all strings of course but represent numbers and uploaded images as well as descriptive text. A unique selection of 20-25 of these skills is associated with each of 30 characters and an article exists for each character to describe their unique set of skills.
 * At least three different templates are used to present different and overlapping subsets of data from each record. As the wiki is new there are gaps in the data and so it is vital to plan for easy and error-free updates and corrections
 * It would be preferable to manage these data revisions at one page for each skill.

OK that's about as concise as I can manage at this late hour! I am new to wikis and don't want to reinvent the wheel here.
 * Is there a best practice for such a situation?

While updating the various template calls the thought occurred to me that each set of |param1 = value1 : records might be stored on one Template:skillname### page for each of the 120-150 skills. After reading this Advanced templates help topic my hopes were raised. I rather naively thought that I could use an embedded template call within each of the three "outer" templates as follows: (spaces added for forum readability only) This did not yield the desired result despite my efforts to escape the pipe character using  |  and  &amp;#124;  within Template:skillname###
 * param2 = value2
 * paramN = valueN
 *  
 *  
 *  

My goal here was something very similar to an associative array which any awk/gawk/perl programmer would be familiar with. Indexing each piece of data by name is preferable to indexing by number for maintainability reasons especially because we want non-technical readers of our game wiki to easily contribute missing pieces of data or correct erroneous data.

What I have unsuccessfully tried to do with this use of Template:skillname### is the C programming equivalent of an #include file insertion.


 * 1) Should I persevere with templates or is there a better approach?
 * If the template path is the way to go then :
 * 1) Are there other special characters I need to be escaping?
 * 2) Are there other subjects akin to substitution that I need to study?

You're attacking the problem from the wrong end. Instead of trying to extract the parameters, you should inject the template. The content page sends the presentation template it want into the data template, which in turn sends its parameters into the presentation template given.


 * Content pages
 * :Someskill -  
 * :List_of_skills -  


 * Skill data
 * Template:Skilldata/Someskill -  
 * Template:Skilldata/Otherskill -  </tt>


 * Skill presentation
 * Template:SkillPage -  This page is about, a skill available to . </tt>
 * Template:SkillListItem -  * ( </tt>

The above is just one of many ways to use the pattern. Subpages for the data is not necessary, they can be primary templates. They can also be located in another namespace, e.g. as subpage of the main content page. With DPL, you can have the main content page also be the data page, and use template substitution in DPL queries to reuse the data with other templates. The sky (and about 2 MB in template inclusions) is the limit. - Dashiva (talk) 16:24, 27 May 2008 (UTC)


 * It looks to me as if this is being overcomplecated. From what I can see just getting an overview of what was said here, this is something you should be using Semantic MediaWiki for. Organizing data spread out over multiple pages, and creating lists and compilations of various portions of that data is what SMW is all about. Wikia does have SMW ready to be enabled on any wiki that asks for it. ~ NOTASTAFF Daniel Friesen (DanTMan, Nadir Seen Fire) (talk) (tricks) (current topic) May 27, 2008 @ 17:23 (UTC)


 * This is exactly what SMW is not about. SMW lets you aggregate, query and all kinds of needlessly fancy things. None of that is needed here. The data is not spread across multiple pages, it's not being combined or split. There's a data set that is to be presented multiple ways, that's all. - Dashiva (talk) 19:13, 27 May 2008 (UTC)


 * No, I don't know if you are right on if it applies to this or not. However you are wrong on what SMW is about. SMW is not about aggregatin, querying, and all that fancy stuff, that is just the extra stuff added to let users use the data the way they want instead of needing to build something to do it themselves. SMW is about Annotation, it is about handling pieces of data which are attached to a resource, in MW's case a page. The users requirements "records ... comprised of 30 pieces of data per skill", "unique selection of 20-25 of these skills is associated with each of 30 characters [each with an article]", and "It would be preferable to manage these data revisions at one page for each skill.", is what lead me to believe that SMW would be useful. Perhaps rather than pointlessly debating whether it's useful or not in this case from an uninformed point of view, the User could show us what is currently being done, and explain what he actually wants of the wiki rather than jumping into a complex set of code which may not be the best option. But it honestly looks like normal programmers tunnel vision focusing to much on the low-level stuff when MW handles the low-level stuff already expecting people to use high-level stuff. Do remember WikiText is not a programming language. Once you start thinking of things like C #includes and arrays, things are straying a little from the point of a templating language. ~ NOTASTAFF Daniel Friesen (DanTMan, Nadir Seen Fire) (talk) (tricks) (current topic) May 27, 2008 @ 19:37 (UTC)

Thank you Dashiva. The framework you have described is working for me. I now understand how passing the name of the "outer" (presentation) template to the "inner" (datarecord) template achieves my stated goal of keeping all data about a skill on the one central (datarecord) page.


 * I did not understand the point you were making about "DPL" or the "2MB of inclusions" limit.

For brevity in my original problem statement, I omitted a requirement to be able to override one or two values in the data record. However, using the framework you have suggested I have been able to achieve this override capability with only a little complexity added to the central data record. (see demo below)

Describing one template as "outer" and implying the other to be "inner" was an unfortunate choice of labels by me. I prefer the labels It seems that a rose by any other name does not smell as sweet!
 * Template:Presentation1 in place of Template:Outer1 and
 * Template:Datarecord1 in place of Template:skillname### (implied to be "inner")

What follows is a short demo that I used to verify my understanding of what you taught me. It is not intended for comment but rather to pass along my learning to anybody else who is searching this forum (as I previously did) with the same outer/inner perspective that I originally had.

Template:Inner
 * contains a single data record comprise of 3 named data fields. Noteworthy is the use of the  </tt> to allow specific fields of the data record to (optionally) be overridden.

Template:Outer
 * contains the desired layout and formatting for presentation of data from one record

came after
 * which also came after


 * Content page Sandbox: calls the Inner (data record) template and passes to it the name of the desired Outer (presentation) template. It optionally passes some override values.

Renders as:

value3 came after

<ul><li>value2 which also came after <ul><li>value1 </li></ul> </li></ul> pqr came after <ul><li>123 which also came after <ul><li>abc </li></ul> </li></ul> xyzzy came after <ul><li>value2 which also came after <ul><li>value1 </li></ul>

</li></ul> xyzzy came after <ul><li>apple which also came after <ul><li>value1 </li></ul> </li></ul>

I think this simple example demonstrates all aspects of what I now need to go implement.

@Daniel I did read about Semantic MediaWiki at Help:Introduction_to_Semantic_MediaWiki. Thank you for that lead.

Najevi 01:37, 28 May 2008 (UTC)