Logic help for blog
Moderator: General Moderators
Logic help for blog
I am creating a class for blog. One that will go along with any blog. My question is how can I render the posts pagewise? Let's say there are 20 posts and I want 5 to show on each page... Now how exactly should I do it? I don't want to know the SQL or similar.. I just want to know how can I create the navigational system? Should I use query strings???
Re: Logic help for blog
Google for "PHP pagination"yoji wrote:I am creating a class for blog. One that will go along with any blog. My question is how can I render the posts pagewise? Let's say there are 20 posts and I want 5 to show on each page... Now how exactly should I do it? I don't want to know the SQL or similar.. I just want to know how can I create the navigational system? Should I use query strings???
There are 10 types of people in this world, those who understand binary and those who don't
Re: Logic help for blog
There's this great article on Sitepoint's site about doing pagination using a strategy object to determine the template of the paginated nav. Basically, your system should take in an array or aggregate object and count how many elements are present. It should know if the current element is the first or last and be able to figure out how many pages are needed based on how many elements are present vs how many elements are needed on a given page. There are lots of ways to do this, but none of them are too hard.