Template:ID to name: Difference between revisions

245 bytes added ,  18:02, 31 July 2019
now works with ~80% of all tables
mNo edit summary
(now works with ~80% of all tables)
Line 1: Line 1:
<includeonly>{{#sub:{{#cargo_query:table={{{2|ItemsTable}}}|where={{#switch: {{{2|ItemsTable}}}| ItemsTable =ObjectID| Mods=ModID| Mutations=MutationID | Factions=FactionID | ObjectID }}='{{{1|}}}'|format=template|template=single query result}}}}</includeonly><noinclude>[[Category:Templates]]
<includeonly>{{#sub:{{#cargo_query:table={{{2|ItemsTable}}}|
fields={{#switch: {{{2|temsTable}}} | Corpses=Title | Cybernetics=Name| _pageName='Page'}}|
where={{#switch: {{{2|ItemsTable}}}| ItemsTable=ObjectID| Mods=ModID| Mutations=MutationID | Factions=FactionID | Corpses=CorpseID | Cybernetics=CyberneticID | ObjectID }}='{{{1|}}}'|format=template|template=single query result}}}}</includeonly><noinclude>[[Category:Templates]]
Basic implementation that searches the objectid in ItemsTable and returns the page name in plain text.
Basic implementation that searches the objectid in ItemsTable and returns the page name in plain text.


Line 8: Line 10:
{{ID to name|Cyclopean Prism}}
{{ID to name|Cyclopean Prism}}


This defaults to Items table, but can search other tables given that they have their own value that stores object id if the table is specified(Not fully implemented)
This defaults to Items table, but can search other tables given that they have their own ID in by specifying the table as the second argument:
 
<syntaxhighlight lang="sql">
{{ID to name|Human Corpse|Corpses}}
</syntaxhighlight>
output:
{{ID to name|Human Corpse|Corpses}}
 
</noinclude>
</noinclude>