CMS Development

Woodsy
Top Contributor

Paginate multiple blogs

Hi all, I have created a blog listing that pulls in multiple blogs. How do I go about setting up the pagination. The standard pagination only works with single blogs.

 

I have found this:
http://designers.hubspot.com/docs/tutorials/combining-multiple-sets-of-blog-posts-into-a-single-list...

 

But I'm not sure what to do with ...
Please note that this technique does not support pagination. Pagination settings in HubSpot will only apply to standard blog listings. If you wanted to paginate content rendered with a HubL function, you would need to use Javascript to paginate the static set of posts.

 

Thanks

1 Reply 1
Jsum
Key Advisor

Paginate multiple blogs

@Woodsy,

 

All the {{ content }} variable contains all of the content for the blog under a specific url (i.e. website.com/blog or website.com/insights). This allows you to reference the content variable and it only consider the data connected to that blog.

 

When you change settings for a blog you can change settings for each blog individual. one of the settings is the amount of posts to show per page on the listing page. This causes the listing page to automatically show a certian number of blogs per page, and the pagination natively works.

 

What you have built is essentially an rss feed containing multiple blog content variables. By doing this you have separated your listing page from Hubspots default logic, the logic that make the pagination work automatically based on settings for instance. I hope that makes since. 

 

By voiding that logic you are now in a position where you need to create this logic yourself and apply it to your custom feed. One sure fire way of doing this is to just use Javascript. 

 

Have your script dynamically count the number of list items, divide the number by the amount of items you want to show per page, and hide the pages not corresponding to the page selected in the pagination controls. This is essentially a tabber function but with the added functionality of splitting a list of items to a dynamically generated number of tabs. 

 

This my help: http://flaviusmatis.github.io/simplePagination.js/ but keep in mind that changes are that script is meant to expect a static number of items so you may have to make adjustments for a dynamic number. I haven't used it myself so idk.

 

It might also be possible to use HubL logic and querys to accomplish this as well. You would need to count the number of items divided by how many you want per page. create an incremental set of links (1, 2, 3, 4, 5) and set a query in the url when these numbers are clicked on (i.e. website.com/blog?page=1). Your loop would contain logic to show the blogs based on the query in the url. This is theoretical though, I haven't tested yet.

0 Upvotes