Do you really require page numbers? I usually find them annoying while paging through a forum, especially if it is quite active. Threads from the bottom of the page get bumped to the next page so you end up seeing the same content again. I much prefer the first page being the current N results, and the next page being the next N results after the last updated time of the last thread on the page. It is also much easier to model with Cassandra.
On Tue, Nov 27, 2012 at 12:19 PM, Sam Hodgson <hodgson_...@hotmail.com>wrote: > Hi All, > > Wondering if anyone has any good solutions to pagination? In particular > enumerating the number of pages and linking to each page, a common feature > in forums. > > This code is untested (using phpcassa) and may need tweaking to get the > correct range of records or maybe completely wrong! however it shows the > concept of taking a page number then pulling out a range of posts belonging > to that page: > > $cf_threads looks like: > thread_ID => (timestamp => post_id) > > if($page > 1) > { > $ranger = ($pagenumber * 20); > $low_ranger = $ranger - 20; > $arr_range = $cf_threads->get("$thread_id" , $columns=null , > $column_start="" , $column_finish="" , $column_reversed=True, > $limit=$ranger); > $arr_page = array_slice($arr_range, $low_ranger , $ranger , TRUE); > }else > { > $arr_page = $cf_threads->get("$thread_id" , $columns=null > , $column_start="" , $column_finish="" , $column_reversed=True, $limit=20); > } > > I think this should be ok? the only concern is if there are some really > long threads when im having to pull the entire CF. > > Another idea involved a schema change and using a super CF to include a > page number as follows: > > Thread_ID => (PageNumber(timestamp => Post_ID)) > > Probably more efficient but generally page numbers go backwards ie page 1 > has newest content so this would complicate things when writing data and > cause load if logic was included to reorganise page numbers etc. > > Cheers > > Sam > http://Newsarc.net > -- Derek Williams