Alcove CMS
Ru

Part II, Data

Pagination

Numbered pages for one alcove, with a pager you write.

paginate: splits the rows of one alcove over numbered pages. The first page is the page that holds the alcove, and page 2 and up are written to path with :n replaced.

The pager markup is yours. A pager file in content/pagers/ lists which parts to show (first, previous, the page numbers, next, last) and the HTML for each, chosen by conditions like tiles.

The live result is a small reading-room bulletin, three entries to a page. The entries are sample data made for this demo.

Live result This page is rendered on request.

  1. Loans in the catalogue

    Books out on loan are now marked on the shelf demo.

  2. The gothic corner

    Mary Shelley moves next to the window, where the light is worst.

  3. Winter hours

    The room stays open late on Thursdays until the end of March.

Source the files behind the result above

content/alcoves/demo_bulletin/alcove.yaml

query: |
  SELECT slug, published, title, summary
  FROM news
  ORDER BY published DESC
paginate:
  per_page: 3
  path: docs/pagination/page/:n
  pager: bulletin

content/pagers/bulletin.yaml

before: 2
after: 2
show: [prev, pages, next]
wrapper: '<nav class="pager" aria-label="Pages of the bulletin">{{ items }}<span class="pager-of">Page {{ pager.current }} of {{ pager.total }}</span></nav>'
items:
  - condition: "kind == 'page' and active"
    html: '<span aria-current="page">{{ n }}</span>'
  - condition: "kind == 'page'"
    html: '<a href="{{ url }}#live">{{ n }}</a>'
  - condition: "kind == 'prev' and exists"
    html: '<a rel="prev" class="turn-link" href="{{ url }}#live">Newer</a>'
  - condition: "kind == 'prev'"
    html: '<span class="turn-link off">Newer</span>'
  - condition: "kind == 'next' and exists"
    html: '<a rel="next" class="turn-link" href="{{ url }}#live">Older</a>'
  - condition: "kind == 'next'"
    html: '<span class="turn-link off">Older</span>'

content/alcoves/demo_bulletin/blueprint.html

<div class="bulletin">
  <ol class="entry-list">{{ tiles }}</ol>
  {{ pager }}
</div>