Need to add pagination to content by label macro
Asked by Karina Green:

Please help, I am new to confluence and need to add pagination to my dynamic pages which are created by using content by label macro.

Is there any code out there with an example of what needs to be done to add pagination to the content by label macro?

Do I need to create a new user macro?


Answers:
author: Shannon S
body: Karina,

The Content by Label macro does not create pages, but rather inserts a macro into your existing page that displays all content in Confluence with a label you specify.

By default, this will show up to 15 pages but can be increased up to 500. There is pagination at the bottom of this macro in order to help you navigate.

If you are dynamically generating pages that contain the Content by Label macro, we'll need to know the process you are using to accomplish this, in order for us to know how to tell you to paginate your results.

Regards,

Shannon

comments: author: Karina Green
body: I am using a label to create my dynamic pages sorted by creation date I am displaying excerpts from different pages with the same label.

If I select to show just 15 excerpts of the query how can I add a page ribbon or next/previous buttons to view the next 15 excerpts on another page?

I need a pagination ribbon or next/ previous button to go to the next 15 excerpts of the content by label query.

If I have 100 documents and I want to show 15 documents per page, I need a way to get to the next 15 documents using pagination.


author: Shannon S
body: Karina,

How exactly are you using the label to create dynamic pages? Is there a script or add-on that you're using?

It's not clear from your description what we're working with here, so please provide more details about this setup and what exactly you did to get this to work.

It sounds like it was something developed in-house, and you might need to speak to the same team who created this in order to add pagination.

Regards,

Shannon


author: Karina Green
body: I think what I am calling dynamic pages are confusing you,so forget i mentioned dynamic pages. I am adding a label video to each of the stories that have been created and then use the content by label macro to pull in excerpts from each of these stories. The page, the content by label macro is on shows 15 story excerpts. I need a page ribbon or a button at the end of this page to show the next 15 story excerpts on another page. I don't want to have all excerpts listed on one page, I want a page ribbon or next/previous link so I can go to the next 15 story excerpts that have the label video.

1 [2](https://bhome.bna.com/media_coverage/?id=12429&page=2) [3](https://bhome.bna.com/media_coverage/?id=12429&page=3) [4](https://bhome.bna.com/media_coverage/?id=12429&page=4) [5](https://bhome.bna.com/media_coverage/?id=12429&page=5) [6](https://bhome.bna.com/media_coverage/?id=12429&page=6) [7](https://bhome.bna.com/media_coverage/?id=12429&page=7) [8](https://bhome.bna.com/media_coverage/?id=12429&page=8) [9](https://bhome.bna.com/media_coverage/?id=12429&page=9) [10](https://bhome.bna.com/media_coverage/?id=12429&page=10) [11](https://bhome.bna.com/media_coverage/?id=12429&page=11) [12](https://bhome.bna.com/media_coverage/?id=12429&page=12) [13](https://bhome.bna.com/media_coverage/?id=12429&page=13) [14](https://bhome.bna.com/media_coverage/?id=12429&page=14) [15](https://bhome.bna.com/media_coverage/?id=12429&page=15) [16](https://bhome.bna.com/media_coverage/?id=12429&page=16) [NEXT](https://bhome.bna.com/media_coverage/?id=12429&page=2) [\>\>](https://bhome.bna.com/media_coverage/?id=12429&page=16)


author: Shannon S
body: Karina,

I see; so to verify, you are splitting your Content by Label results across several pages rather than one page, so the pagination results on the macro itself isn't useful for you.

The main thing I would recommend, which you've probably already done, is have one parent page that collects these pages, and each page with a CBL macro is a child of that page.

You could then use a similar solution to the threads below:

* [Solved: How to add next and previous buttons on each page of the Confluence system automatically?](https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-add-next-and-previous-buttons-on-each-page-of-the/qaq-p/517293)
* [Solved: Macro to read previous and next page in page](https://community.atlassian.com/t5/Confluence-questions/Macro-to-read-previous-and-next-page-in-page/qaq-p/177517)

Unfortunately the **Next and Previous Links** document that is referenced in the second link is no longer available, but you should have the basic idea.

Essentially, you'll need to write a [User Macro](https://confluence.atlassian.com/doc/writing-user-macros-4485.html) to accomplish this.

It might also be worth checking out our [Marketplace Apps](https://marketplace.atlassian.com/search?product=confluence&query=navigation), in case there are any navigation add-ons available to accomplish your requirement.

Regards,

Shannon


author: sean_morgan
body: [@Shannon S](/t5/user/viewprofilepage/user-id/510046) I have a question about
> By default, this will show up to 15 pages but can be increased up to 500. *There is pagination at the bottom of this macro in order to help you navigate.*

Italic emphasis added by me.

I can certainly see in the macro edit where I can control the number of things but don't see anywhere to control or enable pagination or any navigation within the results. The feature you're describing isn't referenced in the [Content by Label Macro documentation](https://confluence.atlassian.com/doc/content-by-label-macro-145566.html) that I can see. Is it specific to a particular version or just to cloud instances?


author: Shannon S
body: Hello Sean,

This is a bit of an older thread, but I made a mistake in interpreting what the macro does, and I've not been able to test this myself as I don't have a Confluence instance that has that many pages in it which are labeled.

The pages that it displays are actual Confluence pages. So, if you want to display 500 pages of Confluence that use that label, the functionality mentioned in [Content by Label Macro documentation](https://confluence.atlassian.com/doc/content-by-label-macro-145566.html) is the one you change:
> **Maximum Number of Pages**
>
> Limit the number of items to include in the list. This can be any value up to 500 pages.

This does not include pagination, as I am now learning. If you want to add pagination you would need to try editing the macro, if you are comfortable with modifying source code. There's one solution here you can try:

* [Pagination With Macro](https://community.atlassian.com/t5/Confluence-questions/pagination-with-macro/qaq-p/49689)

If you still have any issues, I recommend raising a new question, and our Community can help with that. I don't personally have experience with modifying the built-in macros in this way, but I know a lot of our community has and would be able to help you with that.

Regards,

Shannon


Tags: atl-adm

atlassian-marketplace

content-by-label

pagination