What's the best way to display "Showing #-# of # Total" on channel category listing page outside -- and before -- the {exp:channel:entries} tags and pagination?

Here's a PHP solution -- but it's inside the pagination:

Show currently displayed results and total results in pagination

Any help would be greatly appreciated. Thank you.

  • Could you explain what you are trying to paginate - and why it needs to be outside the channel-entries tag? Would help guide you to a useful answer. Oct 4, 2018 at 17:06
  • I'm using paginate for the channel entries. It's a category archive page. And it's outside the channel entries tag simply for layout reasons. Oct 6, 2018 at 3:24
  • If it is just a layout issue, have you thought about simply relocating the pagination block in page layout - either with CSS, or if you are using a layout framework like bootstrap using the layout adjustment such they provide? Oct 6, 2018 at 13:26
  • I have. But it won't be applicable in this case. Can this be done? Oct 6, 2018 at 22:52

1 Answer 1


Original answer updated to use Layout Variables

Pagination by definition is predicated on an understanding of three things

  • how many items there are to be displayed,
  • the index # of the first item to be visible in the window, and
  • how many are currently visible in the sliding window to that collection of items being used for display.

You will already know the third value as you will have set it in the limit parameter of your channel entries tag, but for the other two we need to extract this information from your live channel entries call block. Fortunately EE exposes this information:

With this information you can construct the pagination block manually. There are a variety of ways to do this (Derek Hogue's php solution being just one such). An approach that avoids embeded php would be to use Caddis' excellent Math add-on for EE.

First we need to grab info on what is being displayed currently in the channel entries block - you could use stash or layout variables for this.

To use Layout Variables you first need to create a new template with just your {exp:channel:entries} tag in it (i.e. the tag that generates the output you want to create the pagination string for). Keep your original template (we'll need to modify that in a bit), so choose a new name for the new layout variable one.

Start your new template with a tag to call the original template as the 'next' one in the processing order, and then grab pagination information from the channel entries call. Something like...


{exp:channel:entries ... blah ... limit="YOUR_LIMIT_VALUE"}
{if count == 1}
   {layout:set name="paginate_window_start"}{absolute_count}{/layout:set}
   {layout:set name="paginate_total_results"}{absolute_results{/layout:set}
{layout:set:append name="channel_entries_output"}
                 ... blah ...

When this template is processed two single layout values will be saved from the {if} statement for loop 1, and an array containing one entry output from each loop of the channel for this pagination state.

Now we go to the original template. This template now has the information we captured in the previous template available as layout variables.

We can replace the original {exp:channel:entries} tag with a call to dump out the content of our layout variable array channel_entries_output - something as simple as:


Then somewhere else in your template you will be able to do the maths to work out the values for your pagination string. Something like (using Caddis Math):

  formula="[1] + YOUR_LIMIT_VALUE" 

Of course you may need to do some fine-tuning of this - it is not clear from your question how you control the pagination output of the channel if not via the pagination block - depending on how you do this may affect how you set up the processing. But the general idea hopefully holds.


  • I've been using EE for years and have never used layout variables. Thank you for pointing me in the right direction. I don't think I'm using it correctly though. Here's what I have: <p>Showing {layout:paginate_window_start}-MATH_OR_PHP_HERE of {layout:paginate_total_results} results</p> ... {exp:channel:entries...} {if count == 1} {layout:set name="paginate_window_start"}{absolute_count}{/layout:set} {layout:set name="paginate_total_results"}{absolute_results}{/layout:set} {/if} ... {/exp:channel:entries} Oct 9, 2018 at 6:34
  • This actually outputs "1{/layout:set} 5{/layout:set}" before the first entry. Am I missing something? Oct 9, 2018 at 6:35
  • The trick with layout variables is that they only materialise when you transfer to the next layout in the series (think of them like "embed" variables, but without the overhead). So in one template you can run your channel:entries call, and capture the layout variables. On the next (the one you link to via {layout='_layout_name'}) you can access the layout variables (and the rest of the stuff you generated via {layout:contents}). Works really well, but hard to show in stack-exchange: let me know if you need more info on this etc. Oct 9, 2018 at 9:54
  • Okay. Thanks for the explanation. I decided to try Stash instead. Still not outputting the variables though. If I take the set tags out of the channel entries tag (as a test with just basic text) -- it works. Any ideas why this isn't working? Also -- I don't think the #-# will output the correct numbers if the channel entries tag returns less than the limit. Oct 9, 2018 at 20:57
  • After some reading, it looks like I need to use process="end" in the get tags to change the parsing order. If I do this, the variables are outputted. Except, this is now causing issues with the math/PHP (I've tried both) tag. If I use PHP -- it returns an error and if I use math -- I get a large number. Any ideas? Oct 9, 2018 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.