User:Pinsplash/FGD Template Prototype
Contents
Preface
After recent discussion on Talk:Entity Article Template, I now have a working example template of our vision for issue 4. It's kind of complex, but using it is simple. All of this code will simply have to be integrated into the FGD templates (and by that, I mean things like Template:KV Targetname or Template:O Targetname).
This template code will allow us to filter points of information (keyvalues, outputs, inputs, or even flags) by game. You can actually filter it by anything, but the popular use for this seems like it will be for filtering by game. Unlike I worried before, this will allow us to pull off this entity page overhauling without breaking the currently used template transclusions on hundreds of pages that we can't simply edit all at once.
There is one minor downside though: The templates that have their own FGD templates inside them need extra work to forward their parameters to their "parent" templates. (think of it like instance proxying)
There are 3 distinct sort of "cases":
- ALL the information is displayed. After code is integrated, this is the condition that all entity pages will be on. Technically they're already on this. :p
- Only HL2/base information is displayed. You'll most likely see this on hl2-only entities.
- A mix of HL2 information and any other games as needed.
Changes for entity pages
Hypothetically, the final application of this won't be too drastic of a change. Here's what npc_dog's changes might look like (used in hl2, episodic, and ep2):
{{KV BaseNPC}} {{I BaseNPC}} {{O BaseNPC}}
to
{{KV BaseNPC|shadowbasehl2=1|targetnamebasehl2=1}} {{I BaseNPC|s2007=1|shadowbasehl2=1|targetnamebasehl2=1}} {{O BaseNPC|targetnamebasehl2=1}}
That doesn't look like much huh? Most of the information will already be handled when the code is integrated. After the relevant templates have been altered and the npc_dog page is edited, the page will no longer have anything on it added in later games, such as RunScriptFile
from Left 4 Dead 2.
Another example, the env_player_viewfinder from Portal 2:
{{KV Targetname}} {{I Targetname}} {{O Targetname}}
to
{{KV Targetname|basehl2=1}} {{I Targetname|basehl2=1}} {{O Targetname|basehl2=1}}
These changes will remove all the non-applicable information from l4d2 and asw. What's happening is we're telling the wiki to only show information that's been around since hl2 (which happens to be all we need for this page).
Changes for templates
First, here's the example code I have:
-basehl2 info- {{#if:{{{ep2|}}}|-ep2 info-| }} {{#if:{{{portal|}}}|-portal info-| }} {{#if:{{{tf2|}}}|-tf2 info-| }} {{#if:{{{l4d2|}}}|-l4d2 info-| }} {{#if:{{{portal2|}}}|-portal2 info-| }} {{#if:{{{csgo|}}}|-csgo info-| }} {{#if:{{{ep2|}}}||{{#if:{{{portal|}}}||{{#if:{{{tf2|}}}||{{#if:{{{l4d2|}}}||{{#if:{{{portal2|}}}||{{#if:{{{csgo|}}}||{{#if:{{{basehl2|}}}|| -ep2 info- -portal info- -tf2 info- -l4d2 info- -portal2 info- -csgo info-}}}}}}}}}}}}}}
I know, *puking sounds*. Let's look at this bit by bit.
First section
-basehl2 info-
Placeholder text representing the information in entities that's common to EVERY Source game. Obviously, we would want that to display no matter what parameters are defined. The -
's aren't important, it was just how I showed that it was placeholder.
{{#if:{{{ep2|}}}|-ep2 info-| }} {{#if:{{{portal|}}}|-portal info-| }} {{#if:{{{tf2|}}}|-tf2 info-| }} {{#if:{{{l4d2|}}}|-l4d2 info-| }} {{#if:{{{portal2|}}}|-portal2 info-| }} {{#if:{{{csgo|}}}|-csgo info-| }}
This code here is checking for which games we should be displaying information, and then displaying it if we're trying to. For example {{#if:{{{ep2|}}}|-ep2 info-| }}
contains a parser that will display Episode 2 information (marked by -ep2 info-
) IF AND ONLY IF you were to put |ep2=1
in the space next to the template name when applying on an entity page. If you would not want Episode 2 information displaying, do not add |ep2=1
.
Second section
{{#if:{{{ep2|}}}||{{#if:{{{portal|}}}||{{#if:{{{tf2|}}}||{{#if:{{{l4d2|}}}||{{#if:{{{portal2|}}}||{{#if:{{{csgo|}}}||{{#if:{{{basehl2|}}}||
This simply trucks through each parameter it knows of to see if any of them were defined. If not, the following will appear on the page (this would also include -basehl2 info-
):
-ep2 info- -portal info- -tf2 info- -l4d2 info- -portal2 info- -csgo info-
It's not immediately obvious why I chose to make all information display when no parameters are defined. If we didn't do this, any pages using the template would have automatically displayed basehl2 info. It would have forced us to try and rush changing all the entity pages at top speed. This takes a lot of pressure off us because it won't immediately change the look of every entity page.
There is a }}}}}}}}}}}}}}
line at the very end which tells all the IF parsers to close.
TLDR/Just tell me what to do
Step 1
Find a template like Template:KV Targetname and sort everything by when the keyvalue or input or whatever was added. Put the stuff that's in EVERY Source game at the top.
Step 2
For each game that added something new, add {{#if:{{{gamename|}}}|-gamename info-| }}
. Put the abbreviation of the game where it says gamename
. Put the info for what the game added where it says -gamename info-
(dashes not needed).
Step 3
At the bottom, add {{#if:{{{gamename|}}}||
for each game that added something new. Put the abbreviation of the game where it says gamename
. Once they've all been added, add one more for the stuff that's common to all Source games (name it hl2 or base or whatever). After that, re-paste in all of the information that's NOT common to all Source games.
Finish it off by adding }}
once for every #if
you created under Step 3.
Step 4
Go to an entity page that currently has info that doesn't apply to it and uses the template you've just altered. Find where your template is in the page code, and add |gamename=1
between the template's name and the }}
. The gamename
should be the name of the game that wanted info was added from. See above for examples and explanations.
You can enter the games in any order (chronological makes the most sense). Entering hl2/base in the entity page will make only hl2 info display.
See also
- Help:Templates
- Wikipedia:Help:Template, which was very helpful in creating this code.
- Template:KV Targetname, a template that has been updated for this code.