Gamepedia Help Wiki
Advertisement

This article explains how to add basic markup to a Cargo-generated table without resorting to using |format=template. Briefly, you use CONCAT with escaped wikitext as constant strings along with field names in a comma-separated list to achieve the output you want, and the escaped text will be parsed each line. If this makes sense to you, you can skip the rest of the page; if not then continue reading for a more in-depth explanation.

CONCAT

The basis of this procedure is the SQL function CONCAT. You can make the following (rather useless) query:

{{#cargo_query:tables=Extensions
|where=IsOurs="1"
|fields=CONCAT("Kittens")
}}

Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens, Kittens

We could do a slightly more useful query like this:

{{#cargo_query:tables=Extensions
|where=IsOurs="1"
|fields=CONCAT("Kittens")=Kittens,Name
|limit=3
}}
Kittens Name
Kittens AllSites
Kittens Cache<wbr/>Breaker
Kittens Category<wbr/>Skins

More...

We could also do the following:

{{#cargo_query:tables=Extensions
|where=IsOurs="1"
|fields=CONCAT("Kittens ", Name)=Kittens,_pageName
|limit=3
}}
Kittens _pageName
Kittens AllSites Extension:AllSites
Kittens CacheBreaker Extension:CacheBreaker
Kittens CategorySkins Extension:CategorySkins

More...

And finally, here is a more practical example:

{{#cargo_query:tables=Extensions
|where=IsOurs="1"
|fields=CONCAT("[[",_pageName,"{{!}}",Name,"]]")=Link
|format=table
|limit=3
}}
Link

More...

So now you understand how CONCAT works.

Adding templates to CONCAT

Maybe we want to use {{Link}} instead of writing out CONCAT("[[",_pageName,"{{!}}",Name,"]]") every time. We can do the following:

{{#cargo_query:tables=Extensions
|where=IsOurs="1"
|fields=CONCAT('{{((}}Link{{!}}',_pageName,'{{!}}display=',Name,'{{))}}')=Link
|format=table
|limit=3
}}
Link

More...

What we're doing here is inserting the following text: {{Link|_pageName|display=Name}}, with the special characters in the constant text escaped, and the fields spaced in between. Obviously in this example, the resulting syntax line is less compact than spelling out the link, but this idea generalizes to any template you may want to use, to insert arbitrary markup into a table-format Cargo query. With this method, you can avoid storing any already-marked-up values, and still avoid |format=template in your final query!

Special case: adding line numbers

One special case of this is to use {{Iter}} with no parameters to add a line index:

{{#cargo_query:tables=Extensions
|where=IsOurs="1"
|fields=CONCAT("{{((}}Iter{{))}}")=N,_pageName,Name
|format=table
|limit=3
}}
N _pageName Name
1 Extension:AllSites AllSites
2 Extension:CacheBreaker Cache<wbr/>Breaker
3 Extension:CategorySkins Category<wbr/>Skins

More...

We can also simplify this with creation of a second template, {{IterField}} (this template also includes an automatic reset, so you can reuse the template on the same page without issues):

{{#cargo_query:tables=Extensions
|where=IsOurs="1"
|fields={{IterField}},_pageName,Name
|format=table
|limit=3
}}
N _pageName Name
1 Extension:AllSites AllSites
2 Extension:CacheBreaker Cache<wbr/>Breaker
3 Extension:CategorySkins Category<wbr/>Skins

More...

Required templates

Copy the following to your wiki:

Advertisement