Logic help for blog

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yoji
Forum Commoner
Posts: 25
Joined: Sun Oct 19, 2008 3:09 am

Logic help for blog

Post by yoji »

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???
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Logic help for blog

Post by VladSun »

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???
Google for "PHP pagination"
There are 10 types of people in this world, those who understand binary and those who don't
Theory?
Forum Contributor
Posts: 138
Joined: Wed Apr 11, 2007 10:43 am

Re: Logic help for blog

Post by Theory? »

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.
Post Reply