Difference between revisions of "Template talk:Specs-Link"

From War Thunder Wiki
Jump to: navigation, search
(Question regarding the inner workings of the template)
 
(Response)
Line 1: Line 1:
 
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
 
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
 
--[[User:U41991654|U41991654]] ([[User talk:U41991654|talk]]) 18:14, 4 September 2022 (UTC)
 
--[[User:U41991654|U41991654]] ([[User talk:U41991654|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 <code><nowiki>[[{{#unit:hunter_f1|article}}|Hunter F.1]]</nowiki></code>), 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, <code><nowiki>{{#unit:ID|article}}</nowiki></code> gives the current page title for the given ID, and each vehicle page has the associated vehicle ID as the "code" parameter of the <code><nowiki>{{Specs-Card}}</nowiki></code> 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. - [[User:U38088265|U38088265]] ([[User talk:U38088265|talk]]) 19:51, 4 September 2022 (UTC)

Revision as of 19:51, 4 September 2022

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)