We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Paging help | Forum

Sean
Sean Oct 26 '13
Hi there,


Can someone help me with paging?


I have an sql result returned with about 80 records, I want to display just 10 per page but I'm not sure how paging is implemented in OXWALL.

Daisy Team
Daisy Nov 1 '13
Sean, check the, let's say, Blogs plugin to see how the paging is set.
Simply go to /ow_plugins/blogs/controllers/blog.php file and search for the following string:

$paging = new BASE_CMP_Paging($page, ceil($itemsCount / $rpp), 5);

Also you can check the paging component here: /ow_system_plugins/base/components/paging.php
Sean
Sean Nov 7 '13
Humm, I've done this, and I can see the correct number of paging buttons on the page, but smarty is still showing all records on one page, not splitting them.


I have this html code:


{foreach $pdata as $data}<tr class="{cycle values='ow_alt1,ow_alt2'}"><td><a href="{$links.{$data.master}}"><img src="{$avatars.{$data.master}}" class="ow_avatar" /></a></td><td>{if empty({$data.cr})} - {else}{$data.cr}{/if}</td><td>{if empty({$data.os})} - {else}{$data.os}{/if}</td><td>{if empty({$data.vos})} - {else}{$data.vos}{/if}</td><td>{if empty({$data.ww})} - {else}{$data.ww}{/if}</td><td>{if empty({$data.vg})} - {else}{$data.vg}{/if}</td><td>{if empty({$data.pr})} - {else}{$data.pr}{/if}</td><td><span class="ow_txt_value">{$data.total}</span></td></tr>{/foreach}


Should I add anything there to tell it to limit the records to the paging amount?

Daisy Team
Daisy Nov 11 '13
Go to /ow_plugins/blogs/controllers/blog.php file and search for index function. Here you can find the following strings:

$rpp = (int) OW::getConfig()->getValue('blogs', 'results_per_page');

        $first = ($page - 1) * $rpp;

        $count = $rpp;

This is how the system divides the blog posts per pages.
Petar Šlat
Petar Šlat Nov 12 '13
Quote from Sean Humm, I've done this, and I can see the correct number of paging buttons on the page, but smarty is still showing all records on one page, not splitting them.


// CUT


Should I add anything there to tell it to limit the records to the paging amount?


Yes, you should use LIMIT clause on your SQL query syntax.

As Daisy said above, you will have something like:

$mySql = "SELECT * FROM table LIMIT $first, $rpp";


Hope we helped

o7