mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	lots of pagination work, query params, ajaxify to pids
This commit is contained in:
		
							
								
								
									
										24
									
								
								src/posts.js
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								src/posts.js
									
									
									
									
									
								
							| @@ -468,4 +468,28 @@ var db = require('./database'), | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	Posts.getPidPage = function(pid, callback) { | ||||
| 		Posts.getPostField(pid, 'tid', function(err, tid) { | ||||
| 			if(err) { | ||||
| 				return callback(err); | ||||
| 			} | ||||
|  | ||||
| 			topics.getPids(tid, function(err, pids) { | ||||
| 				if(err) { | ||||
| 					return callback(err); | ||||
| 				} | ||||
|  | ||||
| 				var index = pids.indexOf(pid); | ||||
| 				if(index === -1) { | ||||
| 					return callback(new Error('pid not found')); | ||||
| 				} | ||||
| 				var postsPerPage = parseInt(meta.config.postsPerPage, 10); | ||||
| 				postsPerPage = postsPerPage ? postsPerPage : 20; | ||||
|  | ||||
| 				var page = Math.ceil((index + 1) / postsPerPage); | ||||
| 				callback(null, page); | ||||
| 			}); | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| }(exports)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user