Template talk:Specs-Link
Is there a way to know how this template works exactly? Because the CDK Reference/Units uses this template so much, the time to load the page is at an unacceptable level. Links are convenient though, so I'm looking to know how exactly this template gets a link from a vehicle ID so that I can implement it in my code and pre-process the links instead of having the template process them every time someone tries to load the page --Pwa_ (talk) 18:14, 4 September 2022 (UTC)
- Vehicle codes/IDs are internally mapped to their individual page titles and display names, which are queried and combined via the template to form the formatted links. You appear to have been able to find the display names or some equivalent previously, so you could theoretically cut out half the work by hard-coding them (eg
[[{{#unit:hunter_f1|article}}|Hunter F.1]]
), although this would currently only save 1 second of CPU time out of 5 at present. Otherwise, you would likely have to create your own map of ID to page: if it helps,{{#unit:ID|article}}
gives the current page title for the given ID, and each vehicle page has the associated vehicle ID as the "code" parameter of the{{Specs-Card}}
template at the top of the page. Of course, with hard-coding either the display name or the entire link, you lose the functionality of the link automatically updating if the vehicle's name changes at any point. - DnaGonite (talk) 19:51, 4 September 2022 (UTC)- I think the links not being able to update themselves is an acceptable trade-off, the Units page is updated at least every major update. I've been able to find the display names via the localization files of the game, but I can't find any file that maps the units to a wiki page. Making my own map of ID to page has been on my mind for a while, but while most IDs have straightforward link equivalent, there's an important number of exceptions I have a hard time wrapping my head around. I was wondering how does the template query the links, if it is an API call I could make my script make that call (with appropriate rate-limiting), but I guess even if that was the case, that API would be kept private. Alternatively, would there be a way to make the template only be processed when revealed, instead of when the page loads? --Pwa_ (talk) 10:39, 5 September 2022 (UTC)