Module:CargoQuery/doc: Difference between revisions
(update for to most recent) |
(add compound example) |
||
Line 30: | Line 30: | ||
</pre> | </pre> | ||
Here, the <code>one_to_many</code> is a list of players on the team in question. For each ONE team, there are MANY players, so the field <code>IDs</code> that's sent to the template is a comma-separated list of players, grouped by team page. | Here, the <code>one_to_many</code> is a list of players on the team in question. For each ONE team, there are MANY players, so the field <code>IDs</code> that's sent to the template is a comma-separated list of players, grouped by team page. | ||
== Compound Queries == | |||
You can also run compound queries using <code>compound</code>. It has the same synatax as <code>#cargo_compound_query</code>, but with a few exceptions: | |||
* <code>default</code> for each individual query is disabled; default must be specified outside as an additional argument, which is then applied if both queries do not return. | |||
* Each query must be numbered as in <code>1=(query1)</code>, etc. | |||
=== Example === | |||
<pre> | |||
{{#invoke:CargoQuery|compound | |||
|1=table=Food=F | |||
;fields=F._pageName=Page | |||
;where=F.CookEffect HOLDS 'heat and fire-based' AND F._pageNamespace = '0' | |||
|2=table=Liquids=L | |||
;fields=L._pageName=Page | |||
;where=L.CookEffect HOLDS 'simple heat and fire-based' AND L._pageNamespace = '0' | |||
|default=No Results! | |||
|template=favilink page | |||
|delimiter = <br> | |||
}} | |||
</pre> | |||
<includeonly> | <includeonly> | ||
[[Category:Modules]] | [[Category:Modules]] | ||
</includeonly> | </includeonly> |
Revision as of 11:30, 2 September 2020
This module is taken from Leaguepedia's CargoQuery module.
This module lets you get around the |no html
bug that Cargo has by avoiding |format=template. This module implicitly assumed you ARE using named args in your template (corresponding to |named_args=yes
; you do not need to specify this.)
Unlike |format=template
, this wrapper will NOT rename parameters with underscores in them to use spaces instead.
Parameters
- You may specify all parameters the same as if they were parameters in
#cargo_query
.
One-To-Many
This template allows for one-to-many support, allowing you to specify a field to treat equivalently to a List of ...
field. Syntax is as follows:
|one_to_many=
, a list of fields you want concatenated together.|one_to_many_group=
, the thing you want our one-to-many values grouped by. UNLIKE the|group by=
parameter, this should be the FINAL name of a field, so something on the RIGHT SIDE of the equals sign in your|fields=
parameter.|one_to_many_sep=
, defaults to comma. Currently you must pick the same separator for all of your one-to-many fields.
Example
{{#invoke:CargoQuery|main |table=Teams,ListplayerCurrent=LPC |join on=Teams._pageName=LPC._pageName |where=Teams.Region="North America" AND LPC._pageName IS NOT NULL |fields=Teams._pageName=Page |one_to_many=LPC.ID=IDs |one_to_many_group=Page |one_to_many_sep=, |template=<template> |intro={{(!}} class="wikitable" |outro={{!)}} |limit=10 }}
Here, the one_to_many
is a list of players on the team in question. For each ONE team, there are MANY players, so the field IDs
that's sent to the template is a comma-separated list of players, grouped by team page.
Compound Queries
You can also run compound queries using compound
. It has the same synatax as #cargo_compound_query
, but with a few exceptions:
default
for each individual query is disabled; default must be specified outside as an additional argument, which is then applied if both queries do not return.- Each query must be numbered as in
1=(query1)
, etc.
Example
{{#invoke:CargoQuery|compound |1=table=Food=F ;fields=F._pageName=Page ;where=F.CookEffect HOLDS 'heat and fire-based' AND F._pageNamespace = '0' |2=table=Liquids=L ;fields=L._pageName=Page ;where=L.CookEffect HOLDS 'simple heat and fire-based' AND L._pageNamespace = '0' |default=No Results! |template=favilink page |delimiter = <br> }}