Home > Back-end >  How I can display the number of items on the page I am looking at? (using liquid / ruby on rails / s
How I can display the number of items on the page I am looking at? (using liquid / ruby on rails / s

Time:02-07

Does anyone know how I can display the number of items on the page I am looking at? I only know how to display the total number of items, using {{ paginate.items }}

My goal is to display the following message... "Showing 1 to 8 products from 100" and have this update each time you go to the next page... "Showing 9 to 16 products from 100"...

      <div>
        <p >
          Showing
          <span >{{ what goes here? }}</span>
          to
          <span >{{ what goes here? }}</span>
          products from
          <span >{{ paginate.items }}</span>
        </p>
      </div>

CodePudding user response:

Did you try the documentation? Seems pretty clear and easy to follow.

https://shopify.dev/api/liquid/objects/paginate

CodePudding user response:

You need to do some calculation. The first will be

paginate.current_page * paginate.size 1

The second

max((paginate.current_page 1) * paginate.size 1,paginate.items)

  •  Tags:  
  • Related