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 address Keeps 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.
Title Author Year Genre Pride and Prejudice Jane Austen 1813 novel Emma Jane Austen 1815 novel Persuasion Jane Austen 1817 novel A Christmas Carol Charles Dickens 1843 novella Bleak House Charles Dickens 1853 novel Great Expectations Charles Dickens 1861 novel Frankenstein Mary Shelley 1818 gothic The Last Man Mary Shelley 1826 gothic War and Peace Leo Tolstoy 1869 novel The Death of Ivan Ilyich Leo Tolstoy 1886 novella Ethan Frome Edith Wharton 1911 novella The Age of Innocence Edith Wharton 1920 novel
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_idcontent/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&year-gte=1850#live">genre=novel&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>Good to know {{ no_results }} is true when a filter matched nothing. The blueprint above puts it in data-empty, and the stylesheet shows the empty message.{{ query.name }} prints a value from the address, escaped, for example to refill a search field.A filter applies to every query alcove on the page that has that column. A name that matches no column is ignored and logged. Pager links do not keep the query string, so a filtered list loses its filter on page 2. Previous Migrations and queries
Next Cascading variables