Template:Chapterpage/doc

Purpose
Assist in building header template and block in main namespace. Enters chapter and page numbers so you don't have to. Takes chapter number in url and uses it to look up page range for "from" and "to" attributes in block. Also uses chapter number to make wikilinks to previous and next chapters in header template.

Dependencies
Relies on Scribunto Lua Module:Chapterpage to look up page numbers of chapters, which in turn relies on "Module:Tabular data," which looks up data in .tab files in commons.wikimedia.org.

Usage
Create a JSON file that stores your TOC information, and store it as a .tab file in the Data namespace at commons.wikimedia.org. The file cannot be uploaded. The JSON text must be pasted into a text entry box on the edit page. Each row should have the chapter number and first page of chapter. This should be the page number printed on the page of the physical book. Fields should be named "chapter" and "page". An example .tab file can be found here: https://commons.wikimedia.org/wiki/Data:Signswondersgodw0000wood.tab.

Parameters
Call the template with the following parameters. The chapter number should come from which will probably need the chapter number parsed out of it. For example, if the subpage name is "Chapter 1" then you can obtain just the number with:

Pageoffset is the difference between the page number in the page namespace and the number printed in the physical book. Parameter "data" is the name of the page in the "Data" namespace at Wikimedia Commons. Also include the author and index.

Limitations
This template is for works that have chapter numbers and page numbers. This template will not work for works that have different kinds of numbering systems for articles and sections, like in nature catalogs and works that have chapter names but not numbers.