Template:Chapterpage
![]() | This template uses Lua: |
Purpose
editAssist in building header template and <pages /> 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 <pages /> block. Also uses chapter number to make wikilinks to previous and next chapters in header template.
Dependencies
editRelies 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
editCreate 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
editCall the template with the following parameters. The chapter number should come from {{SUBPAGENAME}} 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:
{{#invoke:String|sublength|s= {{SUBPAGENAME}} |i= 8 }} <pre> 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. <pre> {{Chapterpage | chapter = {{#invoke:String|sublength|s= {{SUBPAGENAME}} |i= 8 }} | pageoffset = 6 | author = Maria Woodworth-Etter | data = Signswondersgodw0000wood.tab | index = Signswondersgodw0000wood.djvu }}
Limitations
editThis 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.