Forum:Template and categorization help

I've got a some-what complicated question. At the Wheel of Time wiki, we have a character template. This template categorizes individual pages based on different fields.

We are trying to implement a new function that categorizes characters based on their last appearence and their last mention. What we would like to do is have this new fucntion "read" another field and detirmine if the categorization needs to be applied to the page.

For example, right now pages are categorized in the "Living", "Deceased" and "Status Unknown" categories based on the template field "status" with parameters of "Alive", "Dead" and "Status Unknown". The new function we are trying to impliment is a "Last appeared" and "Last mentioned" fields. What we would like to happen is for the two new fields to read the "status" field and categorize it only if the status field is set to "Alive" and to suppress categorization if not. For example, a character died as of book 5 but has been mentioned since then and should not be categorized in the "Alive (as of xxx)" category.

Related to this, we would also like to have the "Last mentioned" field take precedent over the "Last appeared" field. For example, a character who was last seen in book 11 but last mentioned in book 12 would need to be categorized in the "Alive (as of book 12)" category.

Any help would be appriciated. Thanks!!! Willie -  HtS  14:49, July 19, 2010 (UTC)
 * Right, that's complicated - probably moreso for me who doesn't have an understanding of your templates, as I don't edit your wiki, you probably know exactly what you want to do. Luckily, MediaWiki has Parser Funtions to help with complex template situations. Remember that templates with a lot of parser funtions are expensive (in processing time) to run by the server, especially if there are a lot of edits to the template. I suggest you sandbox a version of the template and try out the things you're trying to do, before you implement it into the real template.
 * From what I understand, you want to categorize one funtion, if it appeared in another. Thus, the character would appear in the Category: Unless  is set, in which case,.
 * If this is, indeed the case - then the code you'd need is:


 * (BTW, I havn't tested this code, and can't guarantee it's accuracy, it's just an example of how you'd use parser funtions, I'd recommend you read the help page on ParserFuntions, and the help on how to use it in templates and try some out in a sandbox before you commit any changes to the template, or wait until someone who's better at using parser functions than me comes along and changes my code. -- Random Time  15:27, July 19, 2010 (UTC)


 * If then logic is not my strong point but that looks to be missing an itiial test to see if 'Satus' = alive is true, but the basic principle is the same, but the first test needs to be is the character alive ! with the Status then hard coded in the category:name as you have tested it already so the variable is redundant, with just the end of the name based on the content of the variable 'last mentioned' or 'last appeared' IMO. (if the variables content does not follow a set structure you will have loads of 'red link' categories needing defining created by the infoboxes. The variable may be best restricted to being a number only value, with the book as part of the category name. e.g.


 * The second part of your Question which takes precedent would need a second logic test (if true then else) but not sure how to determine if the last mentioned book is higher than the last appeared book number as to me that needs testing as well (if i understand it correctly as both could exist in the template), so a test of is one greater than the other would be needed. As Randomtime says create a test template in a sandbox to check the logic works in all cases possible. - BulldozerD11 17:36, July 19, 2010 (UTC)

Thanks for the help, RandomTime and BuldozerD11. Using some of the coding here gave us a few ideas and we finally got it to work. Thanks for the quick responses and help!! Willie -  HtS  19:55, July 20, 2010 (UTC)