Wednesday, November 26, 2008

HABTM pagination

Hi Guys,

Read the faq and such and this seems bizarre this can't be done with
out special code. I cannot get this to paginate. The following is my
controller action. Why wont paginate work on this.

function cuisine($searchby = null) {

$this->Listing->recursive = 1;

$this->Listing->bindModel(array(
'hasAndBelongsToMany' => array(
'Cuisine')));

$this->set('filters',$this->Listing->Cuisine->find('all',array
('conditions'=>array('Cuisine.id'=>$searchby))), $this->paginate());

//chooses a view file
$this -> viewPath = 'filter';
$this -> render('filter');

}

and my view is the following.

<?php foreach ($filters as $filter): ?>

<?php foreach ($filter['Listing'] as $Listing): ?>

<?php echo $Listing['name']; ?>

<?php endforeach; ?>


<?php endforeach; ?>

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


--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: