Welcome Guest, Not a member yet? Register   Sign In
Pagination help!
#11

[eluser]Ivar89[/eluser]
Thats a very good idea Smile

So I can just tell pagination, in some way, to make rows from the pagebreak?
Ok, now to figure out howTongue

#12

[eluser]aquary[/eluser]
would be more like.... pagination create links like this:

/content/show/1
/content/show/2
/content/show/3

Then in you controller, or view, or even directly in MYSQL, you'd have to grap the content according to the page number.... something like...

Code:
<?
// make the content... pageable
$content=explode('[PAGEBREAK]', $content);
// now you have array of content in pages. so echo it?
echo $content[$page_number-1);
?>

Shouldn't be too bad... and ou could even echo them all with a wrapper block for each of them, so you could use javascript to change the page directly without loading or ajaxing.

Code:
<div class="page">
&lt;!-- page 1--&gt;
</div>
<div class="page">
&lt;!-- page 2--&gt;
</div>
<div class="page">
&lt;!-- page 3--&gt;
</div>
// Then use jQuery or something to show/hide contents base on the number of the page

Huh? sees to be a good idea for me to use it as a kind of pagination for my "sometime as long as bible" blog. :-)
#13

[eluser]Ivar89[/eluser]
MAnI should really make more sites, this is to hard for me atm
could you help me one more time
view
Code:
<div id="viewtext">
      &lt;?php foreach ($pages AS $page):?&gt;
      &lt;?php echo $page->strContent; ?&gt;
      &lt;?php endforeach ?&gt;
     </div>
dbquery
Code:
$data['pages'] = $this->db->select('ID_Page, datPublicationDate, strTitle, strPageName, strMetatags, strKeywords, strContent, strPageUrl, strContentIntro, temTemplate')->where('strPageUrl', $id)->get('tblpage')->result();

How would I implement your solution
#14

[eluser]aquary[/eluser]
Just put the code in to your view. From the query, I'm assuming you are selecting 1 content. You have to change the result part and use row() instead.

Code:
$data['pages'] = $this->db->select('ID_Page, datPublicationDate, strTitle, strPageName, strMetatags, strKeywords, strContent, strPageUrl, strContentIntro, temTemplate')->where('strPageUrl', $id)->get('tblpage')->row();

Now the controller
Code:
$data['page_number']=$page_number; // assume this is the pagenumber
$data['pages']=$this->model->get_pages($id); // assume this is your model
if(empty($data['pages']))
   echo 'page not found'; // a fallback if no data.
else
{
// you would need a total_rows for pagination somewhere,
$total_rows=substr_count('[PAGEBREAK]', $data['pages']->strContent)+1;
// now use it to initialize the pagination
// The load the view
}

The View, no need to use foreach now, since you will have 1 object, or none.
Code:
<div id="viewtext">
      &lt;?php
         $pages->strContent=explode('[PAGEBREAK]', $pages->strContent;
         // Assume you send the page number into the view already
         if(!empty($pages->strContent[$page_number])) // Just some error proof
         {
             echo $pages->strContent[$page_number];
         }
         // OR use foreach on the $pages->strContent to echo all pages, and do something fancy as needed.
      ?&gt;
      &lt;?php endforeach ?&gt;
      &lt;?php echo $this->pagination->create_links();?&gt;
</div>

Should be only this...
#15

[eluser]Ivar89[/eluser]
I'll try that in an hour Smile
if this works I will love you SOOOO much!Tongue
#16

[eluser]Ivar89[/eluser]
I just don't get the page_number... I don't have one lolTongue




Theme © iAndrew 2016 - Forum software by © MyBB