Extension:Cargo/Quick start guide/zh

假设你想创建一个展示你家里所有藏书的wiki. 你希望你的wiki中有两种类型的页面：书，以及作者. 每个书的页面都应包含书名、作者、类型、出版年份，以及总页数. 每个作者页面应该包含作者的名字、国籍，以及你所收藏的他的作品列表.

创建模板
你所要做的最主要的事情是创建两个模板，一个是书，另一个是作者. 如果你安装了Page Forms插件，你可以使用Special:CreateTemplate或Special:CreateClass来创建模板. 另外如果你还安装了Page Schemas插件，你可以使用它的标准“创建/编辑图式”来创建或重新创建Cargo模板.

当然，你也可以手动创建这些模板. 以下是这两个模板可能的样子：

Template:Book

Template:Author

做完这些，你现在就有个信息框样式的模板了，该模板既能够定义数据结构还能够以容易查询的方式存储数据.

You can see in this template examples of calls to the three main parser functions of Cargo: #cargo_declare, #cargo_store and #cargo_query; and hopefully how the three interact together. Note especially the placement of #cargo_declare and #cargo_store: the former in the &lt;noinclude&gt; tag, the latter in the &lt;includeonly&gt; tag.

关于这些模板的其他注意事项：


 * For both templates, the name of the entity, i.e the name of the book or author, is not stored in the template. That is because the name of the page itself will hold the name of that book or author -- and will also be stored in those two tables, in a field named "_pageName".
 * The "Author" template contains, at the end, what is known as an aggregating query, which queries the "Books" table (defined by the other template) and gets the names of all the pages that have the current page among its values for the "Authors" field. (It will then, by default, display that information in a comma-separated list.) This is a very common type of query; it means that you don't need to store the same data in two different pages, because one page can simply query the data.
 * There is one line of this sample code that requires another extension to work: the line in Template:Book which includes calls to both #arraymap and #formredlink, both of which are defined by the Page Forms extension. This line does a rather complex operation: it separates the value of " " into one or more sub-values (splitting by comma), then, for each value, either links directly to that page, if a page with that name already exists; or links to the form for creating that page, using the form definition at "Form:Author". Thus, this template presupposes not only that the Page Forms extension is installed, but that an "Author" form has been created. If you don't have Page Forms installed, you could replace that line with something a lot simpler, like:
 * However, Page Forms is strongly recommended for any wiki that uses Cargo.

创建Cargo表
模板创建之后，还有一件简单的事情要做：为每个模板创建Cargo数据库表. 储存模板时并不会自动完成创建. 有两种选项：


 * For each template, go that template's page, select the "Create data table" tab option (or append  to the URL), then click the "OK" button.
 * From the command line, go to Cargo's  directory and run " ".

做完这些之后，为每个有关模板的数据的表就会被创建，你就随时可以通过点击模板页面的“查看表格”链接看到表的内容.