Template:Paneler/prevnext

From Erfwiki
Jump to navigation Jump to search
Documentation is at Template:Paneler/prevnext/doc. edit

Usage

{{Paneler/prevnext
 |book=article name that goes before the page number (TBFGK, Klog, LIAB, Book5, etc)
 |page=page number
 |panel=panel number (on the page)
}}

Example

The first panel of the first page of Book 4:

{{Paneler/prevnext|book=Book4|page=1|panel=1}}

Next: Book4 1:2


A middle panel of the first page of Book 1:

{{Paneler/prevnext|book=TBFGK|page=1|panel=3}}

Previous: TBFGK 1:2Next: TBFGK 1:4


The last panel of the last page of Book 3:

{{Paneler/prevnext|book=Hvs.tCF|page=145|panel=3}}

Previous: Hvs.tCF 145:2

Code and modifications

In case you'll have to make changes to the template it's important to understand its logic.

The template doesn't render the previous panel link for the first panel of a book or a next link for the last panel of the book. This is determined by "book info" template giving parameters BEGIN and END for the "prev" and "next" pages.

The previos panel is {{#expr:PANEL-1}} unless we're on the first panel of the page (then it's the prev page with the panel number being the panel count of the previous page). The next panel is {{#expr:PANEL+1}} unless we're on the last panel of the page (then it's the next page with panel number 1).

Another exception are LIAB text updates. They don't have panel subpages and list panels=0 in the "book info" template. In those cases the links to them should just be the page links.

The template uses the parameters of the pages defined in the "book info" templates, i.e. {{BOOK_page_info|pagenumber=...|paramname=...}}

Overall, simplified code is

{{#ifeq:PREV,PANEL|BEGIN,1||'''Previous''': [[BOOK {{#ifeq:PANEL|1|{{#ifeq:PREV_PANELS|0|PREV|PREV:PREV_PANELS}}|PAGE:{{#expr:PANEL-1}}}}]]  }}{{#ifeq:NEXT,PANEL|END,PANELS||'''Next''': [[BOOK {{#ifeq:PANEL|PANELS|{{#ifeq:NEXT_PANELS|0|NEXT|NEXT:1}}|PAGE:{{#expr:PANEL+1}}}}]]}}

Where the meaning of the constants is (i.e. you get resulting template by substituting them)

BOOK = {{{book|TBFGK}}}
PAGE = {{{page}}}
PANEL = {{{panel}}}
PANELS = {{BOOK_page_info|pagenumber=PAGE|paramname=panels}}
PREV = {{BOOK_page_info|pagenumber=PAGE|paramname=prev}}
NEXT = {{BOOK_page_info|pagenumber=PAGE|paramname=next}}
PREV_PANELS = {{BOOK_page_info|pagenumber=PREV|paramname=panels}}
NEXT_PANELS = {{BOOK_page_info|pagenumber=NEXT|paramname=panels}}