I did a lot of research before posting this question and couldn't find the answer. I'm sure it's a simple task, but it's going over my head for some reason.
I have a "posts" type page that lists all items in my collection, and a "single post" page to display the contents of the selected post. I have two pagination arrows for going to the previous item and next item. How can I grab the URL for the previous/next posts and display it in my template?
Any help would be appreciated, thanks!
You can do this without using iron router pathFor
by using this package https://github.com/alethes/meteor-pages it give a varies options to use a paginations
Also you may be interest to check this URL's Best pattern for pagination for Meteor http://www.youtube.com/watch?v=WSwe_weshQw
I created sample application which exactly do what you need. Please check it : https://github.com/parhelium/meteor-so-post-next-prev/tree/master
Briefly explanation of important parts of this code ( see repo to find more details ):
Server Side
First you need to have some model:
and publish functions:
The 'tricky' part is how to write queries for taking
next
andprev
posts.and similar :
Note that queries from above publish functions differs in
sort field
.Client Side