Ask a page for one alcove, as html, text or json, and open it in a dialog.
Any page Alcove serves answers ?alcove=name with that one alcove instead of the whole page. The alcove has to be placed on the page directly, in a nook or in the layout. The rest of the query string, the filters and the page's access rule apply as usual, and the answer is cached like the page. mime= picks the form of the answer:
html, the default: a small document with the alcove's markup and, in its head, the global files of the page and the files of each alcove inside.
txt: the markup alone as plain text.
json: the output of the alcove as JSON. Its blueprint has to write valid JSON; the |json filter quotes a value for it.
api: the values of the alcove as JSON, only for an alcove with api: true. Rows are a tiles array and alcoves inside are nested objects.
The first demo asks for the same book in each form. The answers were fetched by this page when it loaded.
A link with data-modal puts this to use. It names the alcove to show, one of the page the link points to. On a click a script asks for ?alcove=name&mime=html, adds the stylesheets and scripts of that alcove that the page does not have yet, and shows the markup in a native <dialog> with a close button. Escape, the button or a click outside closes it. Several names can be listed, data-modal="team, /contact/#map", and /path/#name takes an alcove from another page. If the request fails, or the site is served as plain files, the link just opens its page.
The second demo is a list of books with a quick look link each. The card's stylesheet is loaded only when you open one. The sign-in link shows a form in a dialog: a post inside it is sent from the dialog, an error such as a wrong password is shown in it, and signing in reloads the page you were on.
Live result This page is rendered on request.
Asked from this page just now, the same alcove in four forms. The address is shown above each answer.
slug: docs/dialogs/card
lang: en
title: A book card
alcove: house
meta:
description: One book of the sample library, chosen by slug in the address.
nav: docs
nooks:
main:
- alcove: demo_bookcard