I have single table where i put all the content. Each row is one post. I want to be able to manipulate order of posts so that i can push some of those to the top or bottom…
Also, each post belongs to certain category. (i believe that that additional parameter makes difference when ordering posts within certain category)
Please, give me some hints/code patterns how would you do it?
p.s. i don’t want to add new tables, make more relations, i want it as simple as possible…
I would personally accomplish this by adding a sort_index field to the table with a default value of something like 100. You can then push posts down by decreasing their sort order, or push them to the top by increasing it. By starting with a specific number, you are establishing a baseline for default sorting of posts.
This would use ensure posts with the same sort index get a secondary sorting based on the date they were posted.
It also allows you to then easily automate making the posts fall down in the rankings over time with a small script setup as a cron to decrease the sort index of posts every so often until they hit the default value.