Help:Cargo/attaching tables

What is cargo_attach?
The parser function is used to tell Cargo what pages write rows to certain tables. The parser function has a built-in, so if your template declares a table, there's no need to also attach it to that same template. At most one table can be attached to any single template.

Why use cargo_attach?
When you recreate a Cargo table, Cargo initiates a set of jobs on the server to discover and then update every page that writes rows to that table. The discovery works using WhatLinksHere and the two parser functions and  - each template that claims to write rows is discovered by finding usages of these two parser functions, and then each page that transcludes those templates is then updated by this process.

There's a few reasons you might need to use specifically, instead of just :
 * Since a template can only declare one table, if your template stores to more than one table, you'll have to use for the others.
 * If two templates store to the same table, only one of those templates can have the declaration, so you'll need to attach the table to the other template.
 * Maybe for stylistic / documentation reasons, you want to declare the table in its own template (Leaguepedia does this).
 * Occasionally Cargo randomly bugs and gives you random database errors when you try to declare a template there; a workaround is to move the declaration to another location, and then use an attach from the original template.

Attaching multiple tables to the same template
This is not possible to do, but there is a workaround.

A template can attach at most one table and can declare at most one table. Say Cats needs to attach both and  (this is a fake example, those tables don't actually exist on this wiki).

So Cats attaches the normal way, and then we make a special template called  (the name of this template can be anything, but this is the convention used by Leaguepedia). The code of is the following:

Now at Cats we do the following: Source code about cats More source code even more source code End of source code

Here is actually transcluded into every pages that uses Cats - and that's the point. Each page that uses Cats needs to transclude some template that attaches - since Cats itself can't do that, we use  to accomplish this instead.