Alcove CMS
Ru

Part II, Data

Filtering by address

The query string narrows the rows, always as bound values.

On a page that is rendered on request, the query string narrows the rows. ?genre=gothic keeps the rows whose genre column is gothic. A suffix picks another comparison:

Name in the addressKeeps rows where the column is
genreequal to
year-gt, year-gtegreater than, at least
year-lt, year-lteless than, at most
title-incontains
title-notindoes not contain

The value is always passed to the database as a parameter, never pasted into the SQL. The alcove itself needs nothing special: no setting turns filtering on. Click the links in the live result and watch the address.

Live result This page is rendered on request.

TitleAuthorYearGenre
A Christmas CarolCharles Dickens1843novella
The Death of Ivan IlyichLeo Tolstoy1886novella
Ethan FromeEdith Wharton1911novella

No book matches this address.

Source the files behind the result above

content/alcoves/demo_catalogue/alcove.yaml

query: |
  SELECT b.title, a.name AS author, b.year, b.genre
  FROM books b
  JOIN authors a ON a.id = b.author_id

content/alcoves/demo_catalogue/blueprint.html

<div class="catalogue" data-empty="{{ no_results }}">
  <ul class="filter-links">
    <li><a href="/docs/filtering/#live">All</a></li>
    <li><a href="?genre=novella#live">genre=novella</a></li>
    <li><a href="?genre=gothic#live">genre=gothic</a></li>
    <li><a href="?year-lt=1830#live">year-lt=1830</a></li>
    <li><a href="?title-in=the#live">title-in=the</a></li>
    <li><a href="?genre=novel&amp;year-gte=1850#live">genre=novel&amp;year-gte=1850</a></li>
    <li><a href="?author=Leo+Tolstoy#live">author=Leo Tolstoy</a></li>
    <li><a href="?genre=poetry#live">genre=poetry</a></li>
  </ul>
  <table class="books">
    <thead><tr><th>Title</th><th>Author</th><th>Year</th><th>Genre</th></tr></thead>
    <tbody>{{ tiles }}</tbody>
  </table>
  <p class="empty">No book matches this address.</p>
</div>