database record matching pagination pages |
[eluser]zeromechanic[/eluser]
Hello all, Im a little stuck on the next thing. I want to create a news module for CI. All is working but not what i want with pagination. eg. a user clicks on a menu item say ..../news/4 this is row 4 of my table in dbase. and goes to the page displaying the news. What i want is the following, when the user comes to this page, there has to be pagination directing to older an newer messages. How can i get CI to match this /news/4 with the corresponding page that the pagination class creates. eg news/4 is page 3 in the pagination. viewing the news item is working, and my pagination is working. sow how to combine this two or is there an extention to use dbase rows as links?? can't find any on google (prob wrong seach words) thnx zeromechanic
[eluser]CI_adis[/eluser]
Hi zeromechanic, did you check this tut?? http://net.tutsplus.com/articles/news/co...agination/ regards, Adis
[eluser]zeromechanic[/eluser]
Yes checked it out. As most of the nettut tutorials (i think they are great) in a few day got the basics of codeigniter, which i started to "love". I already solved the issue. It is a few weeks ago, so i have to look in it to post what i did. (order for script is pushed to end of march sow didn't work on it for a while) thnx for your reply
[eluser]zeromechanic[/eluser]
I checked it. I did an arraysearch to get the uri_id's matching This is in my controller : (i use HMVC modulair extentions for my codeigniter) Al basic stuff, as also explained in the tut Code: function index() { The problem in my case was that the pagination(anchors) in the index() was not matching the id's in de lees() function. the pagination in "lees" was messedup, wrong pages eg. wrong pagination, stayed on same pagenumer etc What i did was create an array ($data['link']) as a basic database request from dbase: Code: function getLinks() { Code: function _arraySearch($needle, $haystack) { And did this to my view(it is not supposed to be in an viewfile....... for testing) to get the "read more" anchor to match with the pagination in the read view (lees()) So it wil open the newsmessage and gives the pagination the right page. first page has no uri id in the pagination. therefore the $key is set to empty ($key = '' Code: <?php in the model getdata also , if no uri id is present, set to 0 Code: function getData() { this is working for me. |
Welcome Guest, Not a member yet? Register Sign In |