Extension:Cargo/customizing tables

This article explains how to add basic markup to a Cargo-generated table without resorting to using. 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. You can make the following (rather useless) query:

We could do a slightly more useful query like this:

We could also do the following:

And finally, here is a more practical example:

So now you understand how CONCAT works.

Adding templates to CONCAT
Maybe we want to use Link instead of writing out  every time. We can do the following:

What we're doing here is inserting the following text:, 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 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:

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):

Required templates
Copy the following to your wiki:
 * Iter
 * IterField (optional, you can also just write out the escaping of Iter)
 * Iter
 * IterField (optional, you can also just write out the escaping of Iter)