Filter, sort and paginate in Codeigniter

Posted by Babak on Stack Overflow See other posts from Stack Overflow or by Babak
Published on 2010-03-11T21:04:04Z Indexed on 2010/03/12 17:57 UTC
Read the original article Hit count: 682

Filed under:
|
|
|

Ive recently started using CodeIgniter as I was searching for a very lightweight framework and it seemed to come up as a top choice.

I am new to the whole MVC thing, enjoying it but am stuck with something which seems very simple.

I am coding a CMS and need a way to filter, sort and paginate the results. I am used to doing it with querystrings, so I would have something along the lines of:

articles.php?order=title&sort=desc&filter=articletitle&page=5

I have no idea how I would go about doing this in CI so I just turned on the EnableQueryStrings in the config and it works fine, but i am getting the feeling its probably not the most elegant solution.

I suppose I could have

index.php/articles/index/order/title/sort/desc/filter/articletitle/page/5

but to me this seems very inflexible, what if for example i dont need to sort, how would i make sure i am looking at the correct uri segment?

any ideas?

© Stack Overflow or respective owner

Related posts about codeigniter

Related posts about cms