MODX Community

pdoPage item count

Using pdoPage (with limit set to 6) is there a simply solution to count items, so that I may display “Showing 1 to 6 of 24 items” and update to "Showing 7 to 12 of 24 items etc, when paginating.

1 Like

hmm not sure but there could/should be a text string that you could alter…does it now show any text at bottom of the field? If so that text field can be changed to say what you want it to…

Let’s see what others say, I will also think it over for any other good solution…

Are you using it on a container? Then you could retrieve the number of child’s for that container right?

Also, there is a property on the snippet called “totalVar”.

Take a look at the docs, especially the chunks section. There you can find the default settings for what’s displayed and you can of course change those by setting different values when calling pdoPage.

I’m not entirely sure if it’s possible to show the specific section your navigating in (e. g. 7 to 12) without creating a custom snippet, but you could to use the basic navigation panel and display the total amount after it like this:

//untested

&tplPageWrapper = `@INLINE <div class="pagination"><ul class="pagination">[[+first]][[+prev]][[+pages]] of [[+page.total]] [[+next]][[+last]]</ul></div>`

I’m not wanting to amend the pagination controls that I have already setup. I only want to display an item count. I assumed there would be placeholders for item count.

@ilja-web I am already using the totalVar placeholder, thereforeI think getting the child count from the parent container is the direction I will move forward with. Thanks.

I used the ‘idx’ placeholder as a data attribute to set item count using the following JS on load:

var first_item = $("#items > div").first().data("item");
$( "#start_count" ).text( first_item );

var last_item = $("#items > div").last().data("item");
$( "#end_count" ).text( last_item );

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.