It looks like you're offline.
Open Library logo
additional options menu
Last edited by AgentSapphire
December 15, 2021 | History

Collections: Carousel Examples

Collections are essentially pages of query carousels that look like a row of front-facing book covers on a shelf, colorful and easy to browse.

• For more information on using carousels to create collections, click here.

• To read the QueryCarousel macro in the code, click here.

• To read the ListCarousel macro in the code, click here.

QueryCarousels should be used to run a search query.

ListCarousels should be used for a list of explicitly defined works.

Carousels can be either very general, covering a broad subject like art or a very prolific author such as Stephen King, or very specific, displaying an explicit list of work identifiers. At minimum, a carousel needs a one argument: the query. If you skip the query, you'll get an error.

{{QueryCarousel(QUERY)}}

These are examples of carousels with just the query:

{{QueryCarousel('subject:"dragons"')}}

{{QueryCarousel('key:(/works/OL10673093W OR /works/OL73356W OR /works/OL73385W)')}}

This is an example of a carousel with all the options specified:

{{QueryCarousel('subject:"dragons"', title="Dragons", sort="new", key="", limit=20, search=True, has_fulltext_only=False, url=None)}}

This is boilerplate for a carousel without a title or search, with a limit of 20 and sorted by scans and editions:

{{QueryCarousel('subject:"dragons"', sort="scans,editions", limit=20, has_fulltext_only=False)}}

Table of Contents

  1. Query by Search String
  2. Query by Key
  3. Add a Title
  4. Add a Search Bar
  5. Add a Search Bar and Title
  6. Sort Options
  7. Full Text Only
  8. Limits
  9. Key=?
  10. URL

The query can be any string in a format you'd use in the search bar, such as subject:dragons or author:mccaffrey.

Enclose multi-word search strings in quotes, such as subject:"dragonriders of pern".

For more about search strings, click here.

{{QueryCarousel('subject:"dragons"')}}

Query by Key

The query can be a list of specific works. It's not (yet!) possible to specify the exact order of the book covers. See the sort section for some options.

{{QueryCarousel('key:(/works/OL10673093W OR /works/OL73356W OR /works/OL73385W OR /works/OL73375W OR /works/OL73384W OR /works/OL73382W OR /works/OL73387W)')}}

Add a Carousel Title

Add a title above the carousel, which links to the query page.

See the url section for instructions to override the link destination.

{{QueryCarousel('subject:"dragons"', title="Dragons")}}

{{QueryCarousel('subject:"dragons"', search=True)}}

Add a Title and a Search Bar

The search bar always appears above the title.

{{QueryCarousel('subject:"dragons"', title="Dragons", search=True)}}

Sort Options

You can sort by publication date (oldest or newest) or by the number of scans or editions.

Oldest to Newest

Use sort='old' to list the works by oldest publication date first, which is useful to give you the works of a series in order.

{{QueryCarousel('key:(/works/OL73356W OR /works/OL73385W OR /works/OL73375W OR /works/OL73384W OR /works/OL73382W OR /works/OL73387W)', sort='old')}}

Newest to Oldest

Use sort='new' to list the works by publication date, with the most recently published works appearing first.

{{QueryCarousel('key:(/works/OL73356W OR /works/OL73385W OR /works/OL73375W OR /works/OL73384W OR /works/OL73382W OR /works/OL73387W)', sort='new')}}

Scans, Editions

This option should (and usually does) sort the carousel so that the borrowable works are displayed first.

{{QueryCarousel('key:(/works/OL73356W OR /works/OL73385W OR /works/OL73375W OR /works/OL73384W OR /works/OL73382W OR /works/OL73387W)', sort='scans,editions')}}

Full Text Only

By default, carousels will only include works that are in the lending library. To include all works, set has_fulltext_only=False.

{{QueryCarousel('subject:"dragons"', has_fulltext_only=True)}}

{{QueryCarousel('subject:"dragons"', has_fulltext_only=False)}}

Limits

This is not a limit of how many works the carousel will ever display. Carousels do not have a total limit for how many works they will display. If there are 500 items in a search result for your carousel's query and you keep clicking on the right-hand arrow, the carousel will continue making search queries and rendering the next works until all 500 items have been rendered.

The limit is the number of items retrieved from the search query at a time. The default limit is 20 and should be left at 20, because increasing the limit also increases the loading time.

If you set the limit to less than the number of works the carousel displays, such as in the example of below, the right-hand arrow doesn't ever appear and you won't be able to click to get more entries.

{{QueryCarousel('subject:"dragons"', limit=20)}}

{{QueryCarousel('subject:"dragons"', limit=1)}}

Key=?

The key is the unique name of the carousel.

It is used for both analytics and for receiving the results of "load more" feature. This can be left empty. When left empty, the carousel's key will be generated from the hash of the search query. Since keys must be unique, if you have multiple carousels with the same query, you must assign keys to them.

URL

By default, setting a carousel's title parameter creates a clickable title linked to the search results page for the carousel's query. You can set an explicit alternative url parameter to change that title link. Be sure you use the entire url, starting with https://.

The first carousel below has the default title link, while the second carousel takes you to the Open Library homepage.

{{QueryCarousel('subject:"dragons"', title="Dragons")}}

{{QueryCarousel('subject:"dragons"', title="Dragons", url="https://openlibrary.org")}}

Test ListQuery

{{ListCarousel("/people/mekBot/lists/OL104041L")}}

{{ListCarousel("/people/panfilomaria/lists/OL199150L")}}

{{ListCarousel("/people/jehanni/lists/OL197286L")}}

History

December 15, 2021 Edited by AgentSapphire Added additional text about keys provided by Mignon.
August 6, 2021 Edited by Jenner Add barebones note
August 2, 2021 Edited by Jenner Remove keys
August 2, 2021 Edited by Jenner Three ListCarousel to test uniqueness
June 28, 2021 Created by Drini Copy from previous non-i18ned page