I'd like to make a 'page number' for the pagenation

Hello, I have a question.
I have to use ‘Pagenation’.
This is the link that I’m currently testing.

As shown in the image below, I want the page number to be shown as a number of pages. For example, if it’s 3 pages, 1, 2, 3.
However, there are only ‘previous page’ and ‘next page’ buttons now.
스크린샷 2021-06-04 오후 10.48.32

The second question is, I’d like to put a number on each item. There are 10 posts on one page, numbered from 1 to 10, but on the second page, it doesn’t start from 11, it starts from 1 again.

Can anyone give me a hand?
Please give me some advice…!

Regarding your first question, you can use $pagination->range(): Pagination | Kirby CMS

Second question: How do you generate those numbers? Please provide your template code.

1 Like

First of all, thank you very much for the answer to the first question. I solved the problem! Thank you.

As for the second question, I don’t know what ‘template code’ means. I made the item number of the test link like this…!
But this way, every page starts at number one.
I want to know how to start with 11 from page 2.
Is there a way to use it in Kirby?

//// HTML ////

< li>
< span class="number">< /span>
< span class="listsubject"><?= $item->urltexts() ?>< /span>
< span class="downloadpdf">< a href="<?= $item->pdffiles() ?>" target="_blank" download="">Download PDF</a>< /span>
< /li>

//// CSS ////

.number::before {
    counter-increment: numbering;
    content: counter(numbering);
    width: 25%;
    display: inline-block;

Ok, the stylesheet cannot possibly know anything about the items on other pages, so this approach won’t work here. I’d do this with PHP:

What I wanted to see is the PHP code, in particular the foreach loop that shows me what you are looping through?

I’m sorry… Should I show you like this?

		<ul id="listPage">
			<?php foreach ($list = $page->children()->paginate(10) as $item): ?>
		            <span class="number"></span>
		            <span class="listsubject"><?= $item->urltexts() ?></span>
		            <span class="downloadpdf"><a href="<?= $item->pdffiles() ?>" target="_blank" download>Download PDF</a></span>
		    <?php endforeach ?> 

That’s what I wanted!

You can do it like this:

<?php $list = $page->children() ?>
<ul id="listPage">
    <?php foreach ($list->paginate(10) as $item) : ?>
            <span class="number"><?= $list->indexOf($item) + 1 ?></span>
            <span class="listsubject"><?= $item->urltexts() ?></span>
            <span class="downloadpdf"><a href="<?= $item->pdffiles() ?>" target="_blank" download>Download PDF</a></span>
    <?php endforeach ?>
1 Like

I tried other ways before posting here, but couldn’t find a solution. I’m just starting to learn Kirby, so it’s still difficult.
Thank you so much for helping me solve both problems!

We are always here to help, welcome to Kirby!