Friday, August 31, 2012

show all results option during pagination

Hello,
I needed a option to "show all" during pagination. found this hack and I
added this to my form;

<div class="paging">
<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(),
null, array('class'=>'disabled'));?>
<?php echo $this->Paginator->numbers();?>

<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null,
array('class' => 'disabled'));?>
<?php echo $this->Html->link(__('View All', true), array('action' =>
'index', 'show:all')); //added hack to show all?>
</div>

I pasted a copy of function paginate() into my controller and changed a line
to:
// Show all records ##### ADDED this hack. copied from the core
if ((isset($extra['show']) && 'all' == $extra['show']) ||
(isset($this->params['named']['show']) && 'all' ==
$this->params['named']['show']))
{
$options['limit'] = $defaults['limit'] = $limit = $count;
}

$pageCount = intval(ceil($count / $limit));


works great for index but if I change the action in the view to anything
else I get a warning an no results:
Warning (2): Division by zero in
[C:\xampp\htdocs\bigdojo\app\controllers\users_controller.php, line 821]

821 is this line of code: $pageCount = intval(ceil($count / $limit));

any thoughts or options?
Robert





--
View this message in context: http://cakephp.1045679.n5.nabble.com/show-all-results-option-during-pagination-tp5710865.html
Sent from the CakePHP mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.

No comments: