[Solar-talk] pager + controller + model + view
Jeff Surgeson
solar at 3hex.com
Tue Jul 3 16:12:27 CDT 2007
> Let me share a solution to make controller, model and view walk
> together regarding pagination. It's also a suggestion for
> Please let me know what you think! :)
Rodrigo, works great all 3 adapters.
I have found one thing that I like to do with pagination, when the item count
is less than the item total, in other words there is only one page to
display, I like to suppress the output of the pagination as the generated
output when only one page is not very nice or helpfull.
I do have one query with regards this on the count adapter.
Lets say that the item count is 2 so there is only 1 page with 2 two records
displayed the pager output is
Page 1 of 2
which I do not think it should be doing, this is with default count adapter
config.
This is how I am using it
In my controller....
// Set the pager info using the defaults.
$this->_setPager();
// set up fetch query, build where clause,
// set order page and paging
$params = array(
'where' => $where,
'order' => $order,
'page' => $this->layout_pager['page'],
'paging' => $this->layout_pager['paging'],
);
// get count of pages
$total = $this->_products->countPages($params);
$this->layout_pager['count'] = $total['count'];
// assign everything to the view
$this->items = $this->_products->fetchAll($params);
In my view....
$config = array();
$adapter = 'count';
$href = "products/list/{$this->category}";
$page = $this->layout_pager['page'];
$paging = $this->layout_pager['paging'];
$count = $this->layout_pager['count'];
echo $this->pager($adapter, $config)->fetch($href, $page, $paging, $count);
--
...........::::::...........
Jeff Surgeson / South Africa
More information about the Solar-talk
mailing list