Alcove CMS
Ru

Part II, Data

Cascading variables

An included alcove inherits the row it was included from.

When a tile includes another alcove with {{ alcove:name }}, the included alcove can see the values of that tile's row. It can print them, use them in its tile conditions, and bind them in its SQL as :name.

Below, the outer alcove lists the authors. Its tile includes a second alcove, which runs once per author with :author_id bound to that author's id.

Live result This page is rendered on request.

Jane Austen

born 1775

  • Pride and Prejudice 1813
  • Emma 1815
  • Persuasion 1817

Mary Shelley

born 1797

  • Frankenstein 1818
  • The Last Man 1826

Charles Dickens

born 1812

  • A Christmas Carol 1843
  • Bleak House 1853
  • Great Expectations 1861

Leo Tolstoy

born 1828

  • War and Peace 1869
  • The Death of Ivan Ilyich 1886

Edith Wharton

born 1862

  • Ethan Frome 1911
  • The Age of Innocence 1920

Source the files behind the result above

content/alcoves/demo_authors/alcove.yaml

query: |
  SELECT id AS author_id, name, born
  FROM authors
  ORDER BY born

content/alcoves/demo_authors/tile.html

<section class="author">
  <h3>{{ name }}</h3>
  <p class="born">born {{ born }}</p>
  {{ alcove:demo_authorbooks }}
</section>

content/alcoves/demo_authorbooks/alcove.yaml

query: |
  SELECT title, year
  FROM books
  WHERE author_id = :author_id
  ORDER BY year

content/alcoves/demo_authorbooks/tile.html

<li>{{ title }} <span>{{ year }}</span></li>