[COS Blog Post API] How to implement paging to blog listing
Hi,
API documentation indicates that blog listing supports pagination. Is there any starting point, tutorial or advice how to implement pagination?
Basically what i want to achieve, is that page lists about ten newest blog post and older posts can be loaded via prev (next) buttons.
I’m working on PHP & Javascript. (obviously i don’t have strong coding background)
[COS Blog Post API] How to implement paging to blog listing
Hi, wintertribe,
Not sure, if you still need help but that post might help someone else.
So, if you look closer the HubSpot API's following endpoint https://developers.hubspot.com/docs/methods/blogv2/get_blog_posts, you will see that there are 2 query-filter parameters, "limit" & "offset" and then you also have the "total_count".
With these 3 variables, you can determine which part of the total blog-list you want to get from HS database.
Then, what you will need is a variable "page" that will indicate in which page the user currently is.
So let's take a step closer to a potential scenario:
scenario requirements a) show me the 1st page of my blog, b) each page should contain 8 blog-items
To implement that scenario you could (for example in PHP):
Add "page" URL parameters in your page (PHP):
index.php?page=1