Results per page - User selected?

Highlighted
Shopify Partner
12 0 2

Is it possible to let the user choose how many results per page are shown on a collection?

I know I can set the default, but I was hoping for a way to store a user's selection for their session.

1 Like
Shopify Staff (Retired)
Shopify Staff (Retired)
5841 0 121

You are looking at javascript to accomplish this right now. There is no built in feature for this functionality.

http://shopifyplus.com ::: http://twitter.com/bacchus
0 Likes
Shopify Partner
1187 1 59

You can do this by duplicating collections, a snippet and creating separate collection layouts for each size:

Part 1 - in Theme > Assets > Theme Editor

1. Open collection.liquid template and copy the code.

2. Paste the code into a new snippet called 'collection'

Replace the page size in the paginate tag with a variable 'page-size'. E.g.

{% paginate collection.products by page-size %}

3. Open the collection.liquid template again, and include the snippet we just created, assigning a page size beforehand.

{% assign page-size = 12 %}
{% include 'collection' %}

4. Add an alternative template that is based on collection called 'collection-20'. Edit the new template and change the page size to 20.

{% assign page-size = 20 %}
{% include 'collection' %}

Part 2 - in Collections

1. Create collections for each page size - e.g.

  • Shoes (12 per page)
  • Shoes (20 per page)

Select the template (drop down over on the right hand side of the screen) that matches the page size you are creating.

2. Et Voilà! Now you can create links to the collection you want in your theme.

To save the user's preference for the session, as Jamie says you would need to use javascript to store their preference (using a cookie), then making sure that any links that open a paged collection use the right href.

Take a look at our Apps: www.bookthatapp.com ♥ www.searchifyapp.com ♥ www.productsassistant.com
0 Likes
Shopify Staff (Retired)
Shopify Staff (Retired)
5841 0 121

Ug. I know Gavin :)

I've done similar before, but it's so hard to maintain on collections that change frequently and there is no control over dynamic collections without liquid jumprope. I was thinking something like this: http://tympanus.net/jPaginate/ with a paginate products by 1000. Either way it's sort of lacking. :/

http://shopifyplus.com ::: http://twitter.com/bacchus
1 Like